+ 1

Prime number check

https://code.sololearn.com/c59HnmxEt25C/# this is the most efficient way I could figure out to check if a number is prime, can this function be more optimized? Any advice?

2nd Apr 2020, 6:08 AM
Mark Emad
Mark Emad - avatar
2 Antworten
0
But this will iterate more times ... why is it better ? CarrieForle
2nd Apr 2020, 6:52 AM
Mark Emad
Mark Emad - avatar
0
There are more advanced methods which are especially useful with very large numbers, and have rather complicated mathematical background, eg. Rabin-Miller. Read more on wikipedia https://en.m.wikipedia.org/wiki/Primality_test https://en.m.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
2nd Apr 2020, 9:16 AM
Tibor Santa
Tibor Santa - avatar