I'm guessing you are trying to get the sum where the sum is less than 4million? because that isn't what you are calculating. You are calculating the sum at the 4 millionth index which is completely different.

The reason your answer is wrong (besides your logic being wrong) is that a long can't fit the number you are calculating. The 4 millionth entry in the fibonacci sequence is some number so incredibly large that it is overflowing your long. The overflow will make it wrap back into the negatives (probably multiple times).