cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A094830 #36 Jan 17 2024 09:12:18
%S A094830 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,
%T A094830 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,
%U A094830 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
%N 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.
%C A094830 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
%H A094830 Robert Israel, <a href="/A094830/b094830.txt">Table of n, a(n) for n = 1..10000</a>
%e A094830 a(4)=6 because 4 -> 20 -> 24 -> 44 -> 76 -> 161 -> 199, takes 6 steps to reach a prime.
%p A094830 f:= proc(n) local x,k;
%p A094830 x:= n;
%p A094830 for k from 0 do
%p A094830   if isprime(x) then return k fi;
%p A094830   x:= x + add(t^2, t = convert(x,base,10))
%p A094830 od;
%p A094830 end proc:
%p A094830 map(f, [$1..100]); # _Robert Israel_, Oct 27 2016
%t A094830 p[n_]:=Length[NestWhileList[#+Total[IntegerDigits[#]^2]&,n, !PrimeQ[ #]&]]-1; Array[p,100] (* _Harvey P. Dale_, Dec 03 2011 *)
%o A094830 (PARI) 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
%Y A094830 Cf. A003132, A094877.
%K A094830 base,easy,nonn,look
%O A094830 1,4
%A A094830 _Jason Earls_, Jun 13 2004