OFFSET
1,4
COMMENTS
a(n)=0 if n is a prime.
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(4)=3 because 4->8->16->13 is prime.
a(39)=-1 because 39 -> 39 ->39 ... never reaches a prime.
a(49)=-1 because 49 -> 49 ->49 ... never reaches a prime.
a(69)=-1 because 69 -> 69 ->69 ... never reaches a prime.
a(74)=-1 because 74 -> 39 ->39 ... never reaches a prime.
a(28)=3 because 28 ->26 ->20 ->2.
MAPLE
f:= proc(n) local L;
L:= convert(n, base, 10);
convert(L, `+`)+convert(L, `*`);
end proc:
g:= proc(n) option remember; local v, w;
if n::prime then return 0 fi;
v:= f(n);
if v = n then return -1 fi;
w:= procname(v);
if w = -1 then -1 else w+1 fi
end proc:
map(g, [$1..100]); # Robert Israel, Nov 03 2019
CROSSREFS
KEYWORD
base,easy,sign
AUTHOR
R. J. Mathar, Oct 12 2010
STATUS
approved