Primality by Wilson's theorem: Difference between revisions
Content added Content deleted
(Added Applesoft BASIC, Chipmunk Basic, GW-BASIC, Minimal BASIC, MSX Basic and Quite BASIC) |
Not a robot (talk | contribs) (Add BCPL) |
||
Line 599: | Line 599: | ||
=={{header|BCPL}}== |
|||
<syntaxhighlight lang="bcpl">get "libhdr" |
|||
let wilson(n) = valof |
|||
$( let f = n - 1 |
|||
if n < 2 then resultis false |
|||
for i = n-2 to 2 by -1 do |
|||
f := f*i rem n |
|||
resultis (f+1) rem n = 0 |
|||
$) |
|||
let start() be |
|||
for i = 1 to 100 if wilson(i) do |
|||
writef("%N*N", i)</syntaxhighlight> |
|||
{{out}} |
|||
<pre>2 |
|||
3 |
|||
5 |
|||
7 |
|||
11 |
|||
13 |
|||
17 |
|||
19 |
|||
23 |
|||
29 |
|||
31 |
|||
37 |
|||
41 |
|||
43 |
|||
47 |
|||
53 |
|||
59 |
|||
61 |
|||
67 |
|||
71 |
|||
73 |
|||
79 |
|||
83 |
|||
89 |
|||
97</pre> |
|||
=={{header|C}}== |
=={{header|C}}== |
||
<syntaxhighlight lang="c">#include <stdbool.h> |
<syntaxhighlight lang="c">#include <stdbool.h> |