int num = 0;
int num2 = 1;
int fibonacci
for (int i= 0; i< n; i++)
{
fibonacci = num + num2;
num = num2;
num2 = fibonacci;
}
System.out.print(num);
to find the nth, you have to iterate the step
n
times and only print it when you've finished.
No comments:
Post a Comment