Hi perito. I haven't had time to correct your code, but I ran a simple print test... 281 IS the last prime that your code finds - therefore it is output. You do not implement a check to correctly sum up the numbers. Here's the output from my print test:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 = 281
Here's a different test showing what
sum is at each output:
2(2) 3(5) 5(10) 7(17) 11(28) 13(41) 17(58) 19(77) 23(100) 29(129) 31(160) 37(197) 41(238) 43(281) 47(328) 53(381) 59(440) 61(501) 67(568) 71(639) 73(712) 79(791) 83(874) 89(963) = 281
Since your code requires
consecutive sums, you may wish to try re-initializing
i once it's reached 1000 and the correct answer is still not found(how you do this I leave for you- maybe an outer surrounding loop?). For example, you start off with
int i = 2; and since the sum of the above output is actually 963, it lead me to think you're only ten off... thus what would happen if
i was started or restarted off at 7 instead of 2? It would be ten subtracted- hence, 953. Example, for
int i = 7; we get:
7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 = 953