Project Euler #10 Java solution not working

后端 未结 6 446
春和景丽
春和景丽 2020-12-12 00:01

I\'m trying to find the sum of the prime numbers < 2,000,000. This is my solution in Java but I can\'t seem get the correct answer. Please give some input on what could b

6条回答
  •  不思量自难忘°
    2020-12-12 00:05

    The result will be too large to fit into an integer, so you are getting an overflow. Try using a BigInteger or a long instead. In this case a long is enough.

提交回复
热议问题