Last active
December 13, 2015 18:19
-
-
Save manuj10/4954575 to your computer and use it in GitHub Desktop.
computing fibonacci sum of even numbers upto 4,000000
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main() | |
{ | |
using namespace std; | |
int num=0,num1=1,num0=0,sum=0; | |
while(num<=4000000) | |
{num=num1+num0; | |
num0=num1; | |
num1=num; | |
if(num%2==0) | |
sum+=num; | |
} | |
printf("%d",sum); | |
cin.clear(); | |
cin.ignore(255, '\n'); | |
cin.get(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment