Primality by Wilson's theorem: Difference between revisions

Add Miranda
(Add Draco)
(Add Miranda)
Line 1,658:
Prime factors up to a 100:
<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|Miranda}}==
<syntaxhighlight lang="miranda">main :: [sys_message]
main = [Stdout (show (filter wilson [1..100]) ++ "\n")]
 
wilson :: num->bool
wilson n = False, if n<2
= test (n-1) (n-2), otherwise
where test f i = f+1 = n, if i<2
= test (f*i mod n) (i-1), otherwise</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|Nim}}==
2,093

edits