Fibonacci Number

#include


int main (int argc, const char * argv[])

{

int n, i;
double num1, num2, ans;

num1 = 0;
num2 = 1;

printf("How many numbers would you like to print?\t");

scanf("%d", &n);

printf("\n2\t%.0lf\n",num2);

for(i = 0; i < (n-2); ++i)
{

ans = (num1 + num2);

printf("%d\t%.0lf\n", i+3, ans);

num1 = num2;
num2 = ans;
}


return 0;
}

No comments:

Post a Comment

There was an error in this gadget

Followers

About Me

Dhaka, Dhaka, Bangladesh
..