Saturday, June 18, 2011

Fibonacci Algorithms


#include<iostream>
#include<conio2.h>

using namespace std;

int main()
{
    int a = 1, b = 0, c = 1, d = 1, e = 1;
    scanf("%d",&e);
   
    for (d = 1;d <= e; d++)
    {
        c = a+b;
        printf("%d ",c);
        a = b;
        b = c;
    }

    getch();
    return 0;
}

0 comments: