Dain1234 / Design-and-analysis-algorithm

0 stars 0 forks source link

Fibonnaci series using recurtion #20

Open Dain1234 opened 2 years ago

Dain1234 commented 2 years ago

include

void printFibonacci(int n) { static int n1=0,n2=1,n3; if(n>0) { n3=n1+n2; n1=n2; n2=n3; printf("%d",n3); printFibonacci(n-1); } } int main() { int n; printf("enter the number of elements required:"); scanf("%d",&n); printf("fibonacci series are:"); printf("%d%d",0,1); printFibonacci(n-2); return 0; }