Primality by Wilson's theorem: Difference between revisions
Content added Content deleted
(Added C# version w/ performance comparison to Sieve of Eratosthenes) |
(Add Plain English) |
||
Line 574: | Line 574: | ||
'' builtin: {7919,7927,7933,7937,7949,7951,7963,7993,8009,8011,8017,8039,8053,8059,8069,8081} |
'' builtin: {7919,7927,7933,7937,7949,7951,7963,7993,8009,8011,8017,8039,8053,8059,8069,8081} |
||
"3.4s" |
"3.4s" |
||
</pre> |
|||
=={{header|Plain English}}== |
|||
<lang plainenglish>To run: |
|||
Start up. |
|||
Show some primes (via Wilson's theorem). |
|||
Wait for the escape key. |
|||
Shut down. |
|||
To show some primes (via Wilson's theorem): |
|||
If a counter is past 12, exit. \largest factorial respresentable by signed 32-bit integers |
|||
If the counter is prime (via Wilson's theorem), write "" then the counter then " " on the console without advancing. |
|||
Repeat. |
|||
A prime is a number. |
|||
A factorial is a number. |
|||
To find a factorial of a number: |
|||
Put 1 into the factorial. |
|||
Loop. |
|||
If a counter is past the number, exit. |
|||
Multiply the factorial by the counter. |
|||
Repeat. |
|||
To decide if a number is prime (via Wilson's theorem): |
|||
If the number is less than 1, say no. |
|||
Put the number minus 1 into another number. |
|||
Find a factorial of the other number. |
|||
Bump the factorial. |
|||
If the factorial is evenly divisible by the number, say yes. |
|||
Say no.</lang> |
|||
{{out}} |
|||
<pre> |
|||
1 2 3 5 7 11 |
|||
</pre> |
</pre> |
||