-
fibonacci numbers?????
We are supposed to use a for loop to get and display the first 10 fibonacci numbers. (1, 1, 2, 3, 5, 8, 13, 21, 34, 55) Starting with the 3rd number it is the sum of the previous two. So what kinda of loop or would i have to put in if then statements to get it to work. What about arrays?
-
-
you would use a for loop
first print the first 2 numbers
for (i=0; i<total;i++)
{
num3=num1+num2;
num1=num2;
num2=num3;
// then just your printout being num3
}
the loop will stop when the total amount of times you want it to go through the loop is completed