Answer the question
In order to leave comments, you need to log in
Formula for prime numbers?
I wrote a program where it was necessary to determine a prime number with a minimum amount of code, they suggested a formula: if 2**n%n ==2 then the number is prime, where ** is exponentiation, and% is the remainder of the division, can someone tell me what lies at the base of the formula? (would like to understand how it works)
Answer the question
In order to leave comments, you need to log in
And the point is, how will you raise at least a million to a power, usually the easiest way is to have a ready-made matrix of prime numbers, then there will be only one line of comparison in code
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question