Even Fibonacci numbers

Project Euler problem #2 solution:

#include <iostream>
using namespace std;
int main(){
  unsigned long long sum=44;
  int f1=55, f2=89, f;
  do{
    f=f1+f2;
    f1=f2;
    f2=f;
    if(f2%2==0) sum+=f2;
  }while(f2<=4000000);
  cout << sum;
  system(“pause”);
  return 0;
}

Leave a Reply

Name *
Email *
Website