Log In  


Cart #kapzeruki-0 | 2020-02-12 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

4


Give you some help. Any number that has the last digit of 0, 2, 4, 5, 6, or 8 is not a prime number. Should save on the calculation speed.


@dw817 yeah that‘s kinda integrated in the algorithm. The way it works is that for each candidate it check‘s wether it is dividable by another already found prime number. Starting with 2 (which then get‘s all the numbers ending with 0,2,4,6 and 8), then 3, then 5 and so on.


Before anyone points it out: a friend of mine already found out that I didn‘t catch the error when the program reaches 2^15 (program crashes and show‘s prime number: -1). Will fix that soon!:D



[Please log in to post a comment]