I have to sum all of the even numbers in the fibonacci series less than 4000000. I wrote this program but I don't think it works.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
int main()
{
int j = 1;
int i = 1;
int sum = 0;
cout << j << endl;
while (j<= 4000000 && i <= 4000000)
{
j = j + i;
i = j - i;
if ( j<= 4000000 && i <= 4000000 && j%2 == 0)
{
sum = j + sum;
}
}
cout << sum << endl;
}