Primality by Wilson's theorem: Difference between revisions
Content added Content deleted
(Is Wilson theorem prime testing covered here?) |
(Explain a little bit) |
||
Line 12: | Line 12: | ||
(n-1)!²%n |
(n-1)!²%n |
||
</pre> |
</pre> |
||
The number is a prime number. |
The number is a prime number. % stands for modulo, ! stands for factorial, ² stands for squaring. |
Revision as of 04:31, 1 January 2020
Primality by Wilson's theorem
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
- Task
Write a boolean function that tells whether a given integer is prime.
Remember that 1 and all non-positive numbers are not prime.
Use Wilson's theorem.
Wilson's theorem states that when the following expression [needs verification] evaluates to 1:
(n-1)!²%n
The number is a prime number. % stands for modulo, ! stands for factorial, ² stands for squaring.