Primes usually look odd. They’re literally odd [1], but they typically don’t look like they have a pattern, because a pattern would often imply a way to factor the number.

However, 12345678910987654321 is prime!

I posted this on Twitter, and someone with the handle lagomoof replied that the analogous numbers are true for bases 2, 3, 4, 6, 9, 10, 16, and 40. The following Python code proves this is true.

from sympy import isprime for b in range(2, 41): n = 0 for i in range(0, b): n += (i+1)*b**i for i in range(b+1, 2*b): n += (2*b-i)*b**i print(b, isprime(n))

## Related posts

[1] “All primes are odd except 2, which is the oddest of all.” — Concrete Mathematics