login
A171772
Number of steps needed to reach a prime when the map S(n)+M(n) is applied to n, or -1 if a prime is never reached. Here S(n) and M(N) mean the sum and the product of the digits of n in base 10.
2
1, 0, 0, 3, 0, 2, 0, 2, 2, 2, 0, 1, 0, 3, 1, 1, 0, 1, 0, 1, 1, 3, 0, 4, 1, 2, 1, 3, 0, 1, 0, 1, 2, 1, 1, 2, 0, 2, -1, 4, 0, 4, 0, 5, 1, 2, 0, 6, -1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 0, 3, 0, 2, 2, 2, 1, 7, 0, 3, -1, 1, 0, 1, 0, -1, 1, 3, 3, 1, 0, 3
OFFSET
1,4
COMMENTS
a(n)=0 if n is a prime.
LINKS
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
A variant of A074871.
Sequence in context: A260737 A059339 A241181 * A092735 A035464 A194669
KEYWORD
base,easy,sign
AUTHOR
R. J. Mathar, Oct 12 2010
STATUS
approved