class Main {
public static void main(String[] args) {
int n = 100; // Elementos a generar
for (int i = 0; i < n; i++)
System.out.println("F."+i+": "+fibo(i));
}
public static float fibo(int n) {
if (n == 0 || n == 1)
return 1;
return fibo(n-1) + fibo(n-2);
}
}
Primeros n elementos de la sucesión de Fibonacci
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.