cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A348226 a(n) is the smallest positive integer that when expressed in bases 2 to n, but read in base n, is always prime.

This page as a plain text file.
%I A348226 #31 Nov 22 2021 22:51:07
%S A348226 2,2,43,2,45481,2,65484343,186914543201,50006393431,2
%N A348226 a(n) is the smallest positive integer that when expressed in bases 2 to n, but read in base n, is always prime.
%C A348226 a(n)=2 whenever n is prime.
%C A348226 Proof:
%C A348226 Let n be a prime number.
%C A348226 2 expressed in any base larger than 2 is still 2, which is prime.
%C A348226 2 expressed in base 2 is 10. And 10 read in base n is 1*n + 0 = n, which is prime.
%C A348226 The sequence, even when prime indexes are omitted, is not necessarily increasing.
%C A348226 Proof: a(9) > a(10).
%e A348226 a(4) = 43, because
%e A348226   43 is prime
%e A348226   43 in base 3 is 1121 = 1*3^3 + 1*3^2 + 2*3 + 1 and
%e A348226                          1*4^3 + 1*4^2 + 2*4 + 1 = 89, which is prime;
%e A348226   43 in base 2 is 101011 = 1*2^5 + 0*2^4 + 1*2^3 + 0*2^2 + 1*2^1 + 1 and
%e A348226                            1*4^5 + 0*4^4 + 1*4^3 + 0*4^2 + 1*4^1 + 1 = 1093, which is prime;
%e A348226 and 43 is the smallest positive integer with this property.
%e A348226 a(10) = 50006393431
%e A348226       = 153060758677_9
%e A348226       = 564447201127_8
%e A348226       = 3420130221331_7
%e A348226       = 34550030320411_6
%e A348226       = 1304403114042211_5
%e A348226       = 232210213100021113_4
%e A348226       = 11210002000211222202121_3
%e A348226       = 101110100100100111010000001001010111_2;
%e A348226 if we read these numbers as base-10 numbers, they are all prime. And 50006393431 is the smallest positive integer with this property.
%o A348226 (PARI) isok(k, n) = {for (b=2, n, if (! ispseudoprime(fromdigits(digits(k, b), n)), return (0));); return (1);}
%o A348226 a(n) = my(k=1); while (!isok(k, n), k++); k; \\ _Michel Marcus_, Oct 09 2021
%o A348226 (Python)
%o A348226 from gmpy2 import digits, is_prime, next_prime
%o A348226 def A348226(n): # code assumes n <= 63 or n is prime
%o A348226     if is_prime(n):
%o A348226         return 2
%o A348226     p = 2
%o A348226     while True:
%o A348226         for i in range(n-1,1,-1):
%o A348226             s = digits(p,i)
%o A348226             if not is_prime(int(s,n)):
%o A348226                 break
%o A348226         else:
%o A348226             return p
%o A348226         p = next_prime(p) # _Chai Wah Wu_, Nov 19 2021
%K A348226 nonn,base,more
%O A348226 2,1
%A A348226 _Jesús Bellver Arnau_, Oct 09 2021