0
How do I write a code to show that a number is a prime number
2 Réponses
+ 2
So many questions on Prime number. Please use search option next time.
https://www.sololearn.com/discuss/1789593/?ref=app
https://www.sololearn.com/discuss/554699/?ref=app
https://www.sololearn.com/discuss/1073172/?ref=app
https://www.sololearn.com/discuss/794411/?ref=app
https://www.sololearn.com/discuss/937478/?ref=app
https://www.sololearn.com/discuss/1435230/?ref=app
https://www.sololearn.com/discuss/2168940/?ref=app
https://www.sololearn.com/discuss/1532773/?ref=app
https://www.sololearn.com/discuss/2074669/?ref=app
https://www.sololearn.com/discuss/2067819/?ref=app
https://www.sololearn.com/discuss/1041145/?ref=app
https://www.sololearn.com/discuss/281715/?ref=app
https://www.sololearn.com/discuss/940662/?ref=app
https://www.sololearn.com/discuss/2034183/?ref=app
https://www.sololearn.com/discuss/1071466/?ref=app
https://www.sololearn.com/discuss/1759622/?ref=app
0
https://code.sololearn.com/cwW556PsP9HN/?ref=app
First you have to check if the number is divisible by any other number except 1 before itself.
As 2 is the only even prime number you can make the loop faster by skipping even numbers.
Even this code is not efficient and fast enough to check big numbers.
Hope that helps