login
A048986
Home primes in base 2: primes reached when you start with n and (working in base 2) concatenate its prime factors (A048985); repeat until a prime is reached (or -1 if no prime is ever reached). Answer is written in base 10.
6
1, 2, 3, 31, 5, 11, 7, 179, 29, 31, 11, 43, 13, 23, 29, 12007, 17, 47, 19, 251, 31, 43, 23, 499, 4091, 4091, 127, 4091, 29, 127, 31, 1564237, 59, 4079, 47, 367, 37, 83, 61, 383, 41, 179, 43, 499, 4091, 4091, 47, 683, 127, 173, 113, 173, 53, 191, 4091
OFFSET
1,2
COMMENTS
a(1) = 1 by convention.
The first binary home prime that is not known is a(2295). - Ely Golden, Jan 09 2017
EXAMPLE
4 = 2*2 -> 1010 = 10 = 2*5 ->10101 = 21 = 3*7 -> 11111 = 31 = prime.
MATHEMATICA
f[n_] := Module[{fi}, If[PrimeQ[n], n, fi = FactorInteger[n]; Table[ First[#], {Last[#]}]& /@ fi // Flatten // IntegerDigits[#, 2]& // Flatten // FromDigits[#, 2]&]]; a[1] = 1; a[n_] := TimeConstrained[FixedPoint[f, n], 1] /. $Aborted -> -1; Array[a, 55] (* Jean-François Alcover, Jan 01 2016 *)
PROG
(SageMath)
def digitLen(x, n):
r=0
while(x>0):
x//=n
r+=1
return r
def concatPf(x, n):
r=0
f=list(factor(x))
for c in range(len(f)):
for d in range(f[c][1]):
r*=(n**digitLen(f[c][0], n))
r+=f[c][0]
return r
def hp(x, n):
x1=concatPf(x, n)
while(x1!=x):
x=x1
x1=concatPf(x1, n)
return x
radix=2
index=2
while(index<=1344):
print(str(index)+" "+str(hp(index, radix)))
index+=1
(Python)
from sympy import factorint, isprime
def f(n):
if n == 1: return 1
return int("".join(bin(p)[2:]*e for p, e in factorint(n).items()), 2)
def a(n):
if n == 1: return 1
while not isprime(n): n = f(n)
return n
print([a(n) for n in range(1, 56)]) # Michael S. Branicky, Oct 07 2022
CROSSREFS
KEYWORD
nonn,base,nice
AUTHOR
Michael B Greenwald (mbgreen(AT)central.cis.upenn.edu)
STATUS
approved