#include<stdio.h>
int
main(){
int k,r;
long int i=0,j=1,f;
long int sum = 1;
printf("Enter the number range: ");
scanf("%d",&r);
for(k=2;k<r;k++)
{
f=i+j;
i=j;
j=f;
sum = sum + j;
}
printf("Sum of Fibonacci series is: %ld",sum);
return 0;
}
Sample
output:
Enter
the number range: 4
Sum
of Fibonacci series is: 4
No comments:
Post a Comment