Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main (int argc, const char * argv[])
- {
- int fibone = 1;
- int fibtwo = 2;
- int temp;
- int answer = 0;
- while(fibtwo<4000000){
- temp = fibtwo;
- fibtwo = fibone + fibtwo;
- fibone = temp;
- if(fibtwo%2==0){
- answer +=fibtwo;
- }
- }
- // We add 2 because 2 isn't counted (it gets changed before it can be added)
- std::cout << answer + 2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment