

A094830


Start with x = n, repeatedly replace x with x + sum of squares of digits of x until you reach a prime; sequence gives number of steps.


5



1, 0, 0, 6, 0, 4, 0, 11, 5, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 5, 13, 9, 0, 4, 11, 12, 17, 3, 0, 8, 0, 8, 7, 1, 7, 3, 0, 5, 7, 4, 0, 3, 0, 3, 7, 8, 0, 2, 2, 2, 6, 3, 0, 10, 2, 3, 1, 3, 0, 3, 0, 2, 2, 18, 2, 11, 0, 2, 6, 9, 0, 10, 0, 1, 1, 2, 5, 1, 0, 16, 2, 8, 0, 3, 11, 6, 10, 2, 0, 4, 1, 15, 2, 1, 9, 2, 0, 7, 7, 1
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,4


COMMENTS

It is currently not known if this sequence is well defined, i.e. if for all n>=1 there exists an integer v such that a(n) = v. If the sequence is not well defined then the given programs are incorrect as they will get stuck in an infinite loop for some integers.  Peter Luschny, Oct 28 2016


LINKS

Robert Israel, Table of n, a(n) for n = 1..10000


EXAMPLE

a(4)=6 because 4 > 20 > 24 > 44 > 76 > 161 > 199, takes 6 steps to reach a prime.


MAPLE

f:= proc(n) local x, k;
x:= n;
for k from 0 do
if isprime(x) then return k fi;
x:= x + add(t^2, t = convert(x, base, 10))
od;
end proc:
map(f, [$1..100]); # Robert Israel, Oct 27 2016


MATHEMATICA

p[n_]:=Length[NestWhileList[#+Total[IntegerDigits[#]^2]&, n, !PrimeQ[ #]&]]1; Array[p, 100] (* Harvey P. Dale, Dec 03 2011 *)


PROG

a(n) = my(k=0); while(!isprime(n), d=digits(n); n+=vecsum(vector(#d, i, d[i]^2)); k++) ; k \\ David A. Corneth, Oct 27 2016


CROSSREFS

Cf. A003132, A094877.
Sequence in context: A089841 A202542 A019766 * A196878 A209835 A298528
Adjacent sequences: A094827 A094828 A094829 * A094831 A094832 A094833


KEYWORD

base,easy,nonn,look


AUTHOR

Jason Earls, Jun 13 2004


STATUS

approved



