Skip to content

Instantly share code, notes, and snippets.

@yesidays
Created January 14, 2012 17:38
Show Gist options
  • Save yesidays/1612216 to your computer and use it in GitHub Desktop.
Save yesidays/1612216 to your computer and use it in GitHub Desktop.
code.jobs - Fibonacci - C
#include <iostream>
#include<stdio.h>
int main()
{
int n, a=0, b=1, c=1;
printf("Ingrese el número para genera la serie Fibonacci ");
scanf("%d",&n);
if(n==1)
printf(" %d ",a);
else
if(n==2){
printf(" %d ",a);
printf(" %d ",b);}
else
{
c=2;
printf(" %d ",a);
printf(" %d ",b);
while(c<n)
{
a+=b;
printf(" %d ",a);
c++;
if(c==n)
break;
else {
b+=a;
printf(" %d ",b);
c++;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment