Talk:Euler–Jacobi pseudoprime

message: a^{\frac{n-1}{2}} \equiv 1 \mod n means the same like (a^{\frac{n-1}{2}} \mod n) = (1 \mod n), which you, because 1 \mod n is 1 for every integer greater 1, could substitute to a^{\frac{n-1}{2}} \mod n = 1 .
But you shouldn't do that because you could get a contrdiction:
 if a*n = b*n => a = b
 but
 if a mod n = b mod n !=> a = b (a is not necessarily equal b, if a mod n is equal b mod n)
 let a 4, b 7 and n 3. Then it is true: 4 mod 3 = 7 mod 3, but 4 is not equal 7.
 so it is better to write 4 \equiv 7 \mod 3. It describe a relationship from 4 and 7 to the mod of 3. --217.233.234.42 00:05, 8 Apr 2004 (UTC)
thread_title: Math

message: 561 is not the smallest absolute Euler Pseudoprime
In fact 561 is Euler Pseudoprime to the primebases (2, 13, 19, 43, 47, 53, 59, 67, 83, 89, 101, 103, 127, 137, 149, 151, 157, 179, 191, 223, 229, 239, 251, 257, 263, 271, 281, 293, 307, 331, 349, 353, 359, 373, 383, 389, 409, 421, 433, 443, 457, 461, 463, 467, 491, 509, 523, 557, ). It is not  epsp to 5, , 7, 23, 29, 31, ... .
The smallest absolute epsp is 1729. Then follow 2465 and 15841. --Arbol01 16:11, 26 Dec 2004 (UTC)
thread_title: 561

message: There were a number of omissions in the table.  I wrote some code to do the calculations myself, and have replaced the table with those results.  I verified the results of my program (and thus the table) against OEIS A047713 (base 2 ejpp, checked < 10000), A048950 (base 3 ejpp, checked < 10000), A055551 (number of base 2 ejpp < 10^n, checked for n <= 8).
Here's my Haskell code:
 -- computes (a ^ b) `mod` n efficiently
 modpow :: (Integral a) => a -> a -> a -> a
 modpow a 1 n = mod a n
 modpow a b n = mod ((modpow a (div b 2) n) ^ 2 * (a ^ (mod b 2))) n
 
 -- integer sqrt: floor (sqrt n), aka the largest integer x such that x^2 <= n
 isqrt :: (Integral a) => a -> a
 isqrt n = if (g * g > n) then (g - 1) else g
   where g = isqrti 1 n
 
 isqrti :: (Integral a) => a -> a -> a
 isqrti g n = if (abs (g - g1) <= 1) then (g) else (isqrti (div (g + g1) 2) n)
   where g1 = div n g
 
 primes :: [Integer]
 primes = 2:[x | x <- [3,5..], (all ((/= 0) . (mod x)) (takeWhile ((<=x).(^2)) primes))]
 
 isPrime :: Integer -> Bool
 isPrime x | x <= 1 = False
 isPrime x = all ((/= 0) . (mod x)) (takeWhile ((<= x) . (^2)) primes)
 
 jacobi :: (Integral a) => a -> a -> a
 jacobi _ n | (n < 0 || even n) = error "n must be positive odd integer"
 jacobi a 1                     = 1
 jacobi 2 n                     = if (n `mod` 8 == 1 || n `mod` 8 == 7) then 1 else -1
 jacobi a n | (gcd a n /= 1)    = 0
 jacobi a n | (a > n)           = jacobi (a `mod` n) n
 jacobi a n | (a `mod` 2 == 0)  = (jacobi 2 n) * (jacobi (a `div` 2) n)
 jacobi a n | (a < n)           = if ((a `mod` 4 == 3) && (n `mod` 4 == 3)) then ((-1) * j) else j
   where j = jacobi n a
 
 isEJPrime :: (Integral a) => a -> a -> Bool
 isEJPrime a n | (gcd a n /= 1) = False
 isEJPrime a n | (even n)       = False
 isEJPrime a n                  = (modpow a ((n-1) `div` 2) n) == ((jacobi a n) `mod` n)
 
 ejPseudoPrimes :: Integer -> [Integer]
 ejPseudoPrimes a = [x | x <- [3,5..], isEJPrime a x, not (isPrime x)]
Evand (talk) 13:15, 25 October 2009 (UTC)
thread_title:  Table corrections