Finding the sum of Fibonacci
&&
The series of Fibonacci
soliution::
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int f[100000],i,T,j,a;
scanf("%lld", &T);
for(i=1; i<=T; i++)
{
scanf("%lld %lld", &f[0], &f[1]);
for(j=2; j<100; j++)
{
f[j]=f[j-1]+f[j-2];
}
int z,b,sum=0;
scanf("%lld", &b);
scanf("%lld", &a);
for(z=b; z<=a; z++)
{
sum=sum+f[z-1];
printf(" %lld\n", f[z-1]);
}
printf("sum : %lld\n", sum);
}
return 0;
}
No comments:
Post a Comment