You are checking your list of numbers for divisibility by a small bunch of primes only (2, 3, 5). 49 is obviously not a prime (it’s 7*7), but it will slip through your algorithm and get added to the sum. You could type in another for loop checking for multiples of 7 and so on… but I think you need a more generic way.
Which won’t help you, because next prime is 31, and 31*31 is 961 (not a prime number, and not a multiple of any prime you have checked). This is less than 977 and will get added to your sum, making the result wrong.
You should try to find out a solution that can handle any number (well, any number you can fit into memory, but let’s skip over that ). The solution you have has the problem that for a very big number you will need lots of code, and you’d have to know all the primes less than this number in advance.
As far as I know the sieve should work for any input size. I submitted a solution that uses sieve of Eratosthenes and it can run well up to around 22000 before the FCC code editor warns about a potential infinite loop (which I’m confident is not true).