REM Euler Pseudoprime Test REM Robert Campbell, 970701 DECLARE FUNCTION gcd& (x&, y&) DECLARE FUNCTION powmod& (number&, exponent&, modulus&) PRINT "Test number for primality using Euler test" INPUT "number = "; thenumb& PRINT powmod&(2, thenumb& - 1, thenumb&), powmod&(3, thenumb& - 1, thenumb&), powmod&(5, thenumb& - 1, thenumb&) IF ((powmod&(2, thenumb& - 1, thenumb&) = 1) AND (powmod&(3, thenumb& - 1, thenumb&) = 1) AND (powmod&(5, thenumb& - 1, thenumb&) = 1)) THEN PRINT "Prime (probably, testing w/ bases 2, 3 and 5)" ELSE PRINT "Composite" END IF END FUNCTION powmod& (number&, exponent&, modulus&) e& = exponent& accum& = 1 pow2& = number& WHILE (e& > 0) IF ((e& MOD 2) = 1) THEN accum& = (accum& * pow2&) MOD modulus& pow2& = (pow2& * pow2&) MOD modulus& e& = e& \ 2 WEND powmod& = accum& EXIT FUNCTION END FUNCTION