33 lines
683 B
Java
33 lines
683 B
Java
|
public class Suite {
|
||
|
public static void main(String[] args) {
|
||
|
// suiteArithmetique(5, 5, 3);
|
||
|
// suiteGeometrique(5, 5, 3);
|
||
|
suiteFibonacci(15);
|
||
|
|
||
|
}
|
||
|
|
||
|
public static void suiteArithmetique(int depart, int raison, int k){
|
||
|
for (int i = 0; i < k; i++) {
|
||
|
System.out.println(depart + raison * i);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void suiteGeometrique(int depart, int raison, int k){
|
||
|
for (int i = 0; i < k; i++) {
|
||
|
System.out.println(depart + (int)Math.pow(raison, i));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void suiteFibonacci(int k){
|
||
|
int el1 = 1;
|
||
|
int el2 = 1;
|
||
|
int temp;
|
||
|
for (int i = 0; i < k-2; i++) {
|
||
|
temp = el1;
|
||
|
el1 = el2;
|
||
|
el2 = temp + el2 ;
|
||
|
}
|
||
|
System.out.println(el2);
|
||
|
}
|
||
|
}
|