login
A195302
Xmas tree primes.
3
2, 3, 5, 7, 211, 223, 229, 241, 271, 283, 311, 313, 317, 331, 337, 347, 353, 359, 367, 373, 379, 383, 389, 397, 523, 541, 547, 571, 719, 743, 761, 773, 797, 211151, 211193, 211199, 211229, 211241, 211271, 211283, 211313, 211349, 211373, 211433, 211457, 211499, 211571, 211619, 211643, 211661, 211691, 211727, 211811, 211859, 211877, 211997, 213131
OFFSET
1,1
COMMENTS
A Xmas tree prime is a prime which is a concatenation of a prime with a single digit, a prime with two digits, a prime with three digits, a prime with four digits etc. By definition, the number of digits is a triangular number (A000217). Leading zeros are not allowed for any of the primes.
LINKS
Terry Trotter, POTPOURRI [Warning: As of March 2018 this site appears to have been hacked. Proceed with great caution. The original content should be retrieved from the Wayback machine and added here. - N. J. A. Sloane, Mar 29 2018]
EXAMPLE
359 is a Xmas tree prime because it is prime and 3 and 59 are prime.
503 is not a Xmas tree prime although 5 and 3 are prime, because the leading 0 in front of the 3 is not allowed by definition.
MAPLE
isA000217 := proc(n)
for k from 0 do
if n = k*(k+1)/2 then
return k;
elif n < k*(k+1)/2 then
return -1 ;
end if;
end do;
end proc:
isA195302 := proc(n)
local dgs, T, d, std, kList, k ;
if isprime(n) then
dgs := convert(n, base, 10) ;
T := isA000217(nops(dgs)) ;
if T > 0 then
std := 1 ;
for d from T to 1 by -1 do
kList := [op(std..std+d-1, dgs)] ;
if op(-1, kList) = 0 then
return false;
end if;
k := add(op(i, kList)*10^(i-1), i=1..nops(kList)) ;
if not isprime(k) then
return false;
end if;
std := std+d ;
end do:
return true;
else
false;
end if;
else
false;
end if;
end proc:
for i from 2 to 300000 do
if isA195302(i) then
printf("%d, ", i) ;
end if;
end do: # R. J. Mathar, Sep 20 2011
PROG
(Python)
from sympy import isprime, sieve
from itertools import product
def alst(n):
alst, plen = [], 1
while True:
sieve.extend(10**plen-1)
primes = list(str(p) for p in sieve._list)
primesbylen = [[p for p in primes if len(p)==i+1] for i in range(plen)]
for t in product(*primesbylen):
intt = int("".join(t))
if isprime(intt): alst.append(intt)
if len(alst) == n: return alst
plen += 1
print(alst(57)) # Michael S. Branicky, Dec 26 2020
CROSSREFS
Cf. A195335.
Sequence in context: A360986 A122764 A256886 * A064157 A257483 A178371
KEYWORD
nonn,base
AUTHOR
Kausthub Gudipati, Sep 16 2011
STATUS
approved