OFFSET
0,1
COMMENTS
After 100 steps enters a cycle of length 307: a(n+307)=a(n) for n>100; a(167) = 88703778700083013187738001 is the largest term. - Reinhard Zumkeller, Sep 15 2011
LINKS
Reinhard Zumkeller and Chai Wah Wu, Table of n, a(n) for n = 0..10000 First 1001 terms from Reinhard Zumkeller.
EXAMPLE
a(100)^2 = 46629^2 = 2174263641 --> 1731 = a(301);
a(407)^2 = 646^2 = 417316 --> 1731 = a(408) = a(301+307).
MATHEMATICA
nxt[n_]:=Module[{idn=IntegerDigits[n], idn2=IntegerDigits[n^2]}, Table[ idn2= DeleteCases[ idn2, idn[[i]]], {i, Length[idn]}]; FromDigits[idn2]]; NestList[nxt, 2, 30] (* Harvey P. Dale, Oct 29 2011 *)
PROG
(Haskell)
a045541 n = a045541_list !! n
a045541_list = 2 : f 2 where
f x = x' : f x'
where x' = read $ filter (`notElem` show x) $ show (x^2)
-- Reinhard Zumkeller, Sep 15 2011
(Python)
A045541_list, l = [2], 2
for _ in range(10**4):
....l = int(''.join(d for d in str(l**2) if not d in set(str(l))))
....A045541_list.append(l) # Chai Wah Wu, Jan 03 2015
(PARI) deldig(n, m)=my(s=Set(digits(m))); fromdigits(select(k->!setsearch(s, k), digits(n)))
a(n)=if(n, my(k=a(n-1)); deldig(k^2, k), 2) \\ Charles R Greathouse IV, Jun 16 2015
CROSSREFS
KEYWORD
AUTHOR
STATUS
approved