Project Euler #3 out of integer range java [duplicate]

≡放荡痞女 提交于 2019-12-02 07:36:45

600851475143 of type int is out of range

  • This number is bigger than int can store. Appending .0 to the number converts the number into a double which can represent that number
  • Instead of .0 you can do checkFactors(600851475143d) which ensure the number is a double and not an int

Use long as a data type for na and also biggestPrimeFactor. The values are too large for storing in an int variable.

Try to make Your parameter back to long and make letter L after your large number like this 600851475143L, I think it will work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!