Wilson primes of order n: Difference between revisions

→‎{{header|ALGOL 68}}: Should also test for p being prime ...
(→‎{{header|Visual Basic .NET}}: Include in the BASIC section)
(→‎{{header|ALGOL 68}}: Should also test for p being prime ...)
Line 28:
# ( ( n - 1 )! x ( p - n )! - (-1)^n ) mod p^2 = 0 #
PR read "primes.incl.a68" PR # include prime utilities #
[]BOOL primes = PRIMESIEVE 11 500000; # sieve the primes to 11 500 #
# returns TRUE if p is an nth order Wilson prime #
PROC is wilson = ( INT n, p )BOOL:
Line 50:
IF is wilson( n, 2 ) THEN print( ( " 2" ) ) FI;
FOR p FROM 3 BY 2 TO UPB primes DO
IF is wilson( n,primes[ p )] THEN print( ( " ", whole( p, 0 ) ) ) FI
IF is wilson( n, p ) THEN print( ( " ", whole( p, 0 ) ) ) FI
FI
OD;
print( ( newline ) )
3,038

edits