|
EXAMPLE
|
The base-3 representation of 251 is 100022. Base-3 numbers that can be obtained by switching any two adjacent base-3 digits are 10022 and 100202. These two numbers are 89 and 263, respectively, when converted to decimal, and both 89 and 263 are prime. Since 251 is the 12th number with this property in base 3, A(3, 12) = 251.
Array starts
11, 191, 223, 227, 2111, 3847, 229631, 246271, 262111, 786431, 1046527, 1047551
2, 5, 7, 17, 31, 41, 53, 157, 229, 239, 241, 251
2, 3, 7, 13, 23, 29, 47, 53, 101, 127, 149, 151
2, 3, 7, 11, 13, 17, 19, 23, 43, 131, 281, 311
2, 3, 5, 11, 31, 47, 71, 83, 103, 107, 151, 191
2, 3, 5, 11, 13, 17, 19, 23, 29, 37, 41, 43
2, 3, 5, 7, 13, 29, 31, 41, 43, 47, 59, 61
2, 3, 5, 7, 11, 13, 17, 19, 23, 37, 43, 47
2, 3, 5, 7, 13, 17, 31, 37, 71, 73, 79, 97
2, 3, 5, 7, 13, 17, 19, 23, 29, 31, 37, 43
2, 3, 5, 7, 11, 17, 61, 67, 71, 89, 137, 163
|
|
PROG
|
(PARI) switchdigits(v, pos) = my(vt=v[pos]); v[pos]=v[pos+1]; v[pos+1]=vt; v
decimal(v, base) = my(w=[]); for(k=0, #v-1, w=concat(w, v[#v-k]*base^k)); sum(i=1, #w, w[i])
is(p, base) = my(db=digits(p, base)); if(vecmin(db)==1 && vecmax(db)==1, return(0)); for(k=1, #db-1, my(x=decimal(switchdigits(db, k), base)); if(!ispseudoprime(x), return(0))); 1
array(n, k) = for(x=2, n+1, my(i=0); forprime(p=1, , if(is(p, x), print1(p, ", "); i++); if(i==k, print(""); break)))
array(6, 10) \\ print initial 6 rows and 10 columns of array
|