Created
January 14, 2012 17:38
-
-
Save yesidays/1612216 to your computer and use it in GitHub Desktop.
code.jobs - Fibonacci - C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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