%I #36 Jul 13 2015 21:26:14
%S 2,4,16,25,6,3,9,81,656,43033,18518989,3422322,11718787168,
%T 33299240224,118856557176,42330949,17161,29449992,867300880006,
%U 522114591215,760366360676,5815244491919,3370600766306,11949525822594424885
%N Square previous term and then delete digits of previous term.
%C 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
%H Reinhard Zumkeller and Chai Wah Wu, <a href="/A045541/b045541.txt">Table of n, a(n) for n = 0..10000</a> First 1001 terms from Reinhard Zumkeller.
%H <a href="/index/Rec#order_307">Index entries for linear recurrences with constant coefficients</a>, order 307.
%e a(100)^2 = 46629^2 = 2174263641 --> 1731 = a(301);
%e a(407)^2 = 646^2 = 417316 --> 1731 = a(408) = a(301+307).
%t 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 *)
%o (Haskell)
%o a045541 n = a045541_list !! n
%o a045541_list = 2 : f 2 where
%o f x = x' : f x'
%o where x' = read $ filter (`notElem` show x) $ show (x^2)
%o -- _Reinhard Zumkeller_, Sep 15 2011
%o (Python)
%o A045541_list, l = [2], 2
%o for _ in range(10**4):
%o ....l = int(''.join(d for d in str(l**2) if not d in set(str(l))))
%o ....A045541_list.append(l) # _Chai Wah Wu_, Jan 03 2015
%o (PARI) deldig(n,m)=my(s=Set(digits(m)));fromdigits(select(k->!setsearch(s,k), digits(n)))
%o a(n)=if(n, my(k=a(n-1)); deldig(k^2,k), 2) \\ _Charles R Greathouse IV_, Jun 16 2015
%K base,nonn,nice,look,easy
%O 0,1
%A _Erich Friedman_
|