Fibonacci algorithm
package mylibrary;
public class Series {
public static void fibonacci(int n) {
int a = 0;
int b = 1;
int fibonacci = 0;
for (int i = 0; i < n; i++) {
System.out.println(fibonacci);
a = b;
b = fibonacci;
fibonacci = a + b;
}
}
}
package mylibrary;
public class Series {
public static void fibonacci(int n) {
int a = 0;
int b = 1;
int fibonacci = 0;
for (int i = 0; i < n; i++) {
System.out.println(fibonacci);
a = b;
b = fibonacci;
fibonacci = a + b;
}
}
}
Комментарии
Отправить комментарий