Friday, November 2, 2018

URI 1151 Solution in C | Easy Fibonacci

/*Before seeing the code solution make sure that you have tried enough. Don’t copy- paste the whole code. Find out the logic. If you face any trouble, just inform me in comment.*/



#include<stdio.h>
main()
{
    int a,b,c,i,n;
    scanf("%d",&n);
    a=0,b=1;

    for(i=1;i<=n-1;i++)
    {
        printf("%d ",a);
        c=a+b;
        a=b;
        b=c;

    }
    printf("%d\n",a);
    return 0;
}


 //Happy_Coding

1 comment: