OFFSET
2,1
COMMENTS
After a prime is reached it repeats itself infinitely. That's why this prime is then called the "home prime": it is the end of the calculation chain for a specific number.
EXAMPLE
For n=4 we get the base-independent home prime 41 through this chain of calculations:
4 = 2 * 2 -> 22_3 (base 3 because 3 = greatest prime factor (2) + 1)
22_3 = 8_10 = 2 * 2 * 2 -> 222_3
222_3 = 26_10 = 2 * 13 -> 2D_14
2D_14 = 41_10, which is a prime. This gives us 41 as our home prime for n = 4, 8, 26 and 41.
MAPLE
b:= n-> (l-> (m-> add(l[-i]*m^(i-1), i=1..nops(l)))(1+
max(l)))(map(i-> i[1]$i[2], sort(ifactors(n)[2]))):
a:= n-> `if`(isprime(n), n, a(b(n))):
seq(a(n), n=2..77); # Alois P. Heinz, Jan 09 2021
PROG
(PARI) f(n) = my(f=factor(n), list=List()); for (k=1, #f~, for (j=1, f[k, 2], listput(list, f[k, 1]))); fromdigits(Vec(list), vecmax(f[, 1])+1); \\ A340393
a(n) = my(p); while (! isprime(p = f(n)), n = p); p; \\ Michel Marcus, Jan 07 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
S. Brunner, Jan 06 2021
STATUS
approved