diff --git a/Solutions/even-fibonacci.cpp b/Solutions/even-fibonacci.cpp new file mode 100644 index 0000000..5a8be09 --- /dev/null +++ b/Solutions/even-fibonacci.cpp @@ -0,0 +1,30 @@ +/*Given a number N, we have to find the sum of even fibonaccci nos. + less than the given number N. + Code by iamJL + */ +#include +using namespace std; +int fib[10000]; +int main() +{ + int t; + cin>>t; + fib[0]=1,fib[1]=2; + while(t--) + { + int n,i=2; + cin>>n; + int sum = 2; + while(1) + { + fib[i]=fib[i-1]+fib[i-2]; + if(fib[i]>n) + break; + if(fib[i]%2==0) + sum+=fib[i]; + i++; + } + cout<