Hi, I'm still following the same tutorial (This is NOT homework) and there's this problem in which you have to print X amount of Fibonacci numbers (I chose the first 10 numbers), but the program should get the numbers by itself.
For those who don't know, Fibonacci was a mathematician who came up with a series to solve a problem. The series goes like this: 0,1,1,2,3,5,8,13,21 . Each number is the sum of the 2 numbers before that number (3+5=8 and 8+5=13).
Given that F(n)=F(n-2)+F(n-1) and F(0)=1 and F(1)=1 (The tutorial gives this info too..)
This is the code that I have...
I tried adding a variable that represents the last number (F(n-1)) but it didn't really work so I scratched that.Code:#include <stdio.h> int main() { int x,f; for (x=1, f=0;x<=10;f=(x-2)+(x-1),x+=1){ printf("The first ten numbers of the Fibonacci series are %d\n", f); } }
Thanks
Alastor