Log In  

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

P#73029 2020-02-12 18:25

:: dw817

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.

P#73044 2020-02-13 03:21

@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.

P#73058 2020-02-13 10:55

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

P#73059 2020-02-13 10:58

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-02-21 07:27 | 0.024s | 2097k | Q:38