#include <stdio.h>
#include <math.h>
int main()
{
long double n , first =-1 , second = 1 , sum = 0 , third ;
int i = 0 ;
printf("Enter the range: ");
scanf("%LF" , &n );
for (int i = 0 ; i < n ; i++)
{
third = first + second ;
sum = sum + third ;
first = second ;
second = third ;
}
printf("Sum of Fibonacci series for given range is: %.0Lf\n" , sum);
return 0 ;
}
No comments:
Post a Comment