%I #36 Oct 27 2023 22:05:38
%S 2,4,16,136,1936,181936,164181936,13616164181936,
%T 193613613616164181936,1819361936193613613616164181936,
%U 1641819361819361819361936193613613616164181936
%N a(1) = 2; thereafter a(n) is the number obtained by replacing each digit of a(n-1) with its square.
%H John Cerkan, <a href="/A061588/b061588.txt">Table of n, a(n) for n = 1..18</a>
%H William Davidson, <a href="https://www.maa.org/sites/default/files/pdf/abstracts/mf2012_abstracts.pdf">Introducing the peculiar 'Davidson Sequence'</a>, MathFest 2012; see p. 37.
%F From _William Davidson_, Aug 15 2012: (Start)
%F For integer n > 5,
%F a(n) = a(n-4)*10^(L(a(n-5))+L(a(n-1))) + a(n-5)*10^(L(a(n-1))) + a(n-1), where L(x) is the number of digits in x.
%F L(a(n)) = (W^(n-1)*[s1]^T)^T*[d]^T, where W is the 5 X 5 square matrix [(0 1 0 0 0) (0 0 1 0 0) (0 0 0 1 0) (0 0 0 0 1) (1 1 0 0 1)], [s1] = [1 2 3 4 6], [d] = [1 0 0 0 0], and T denotes transpose.
%F To determine the initial digits of a(n), n > 5, let b = ((n+2) mod 4) + 2. Then a(n) begins with a(b). E.g. let n = 100, b = 4, then a(100) = 1936... (End)
%e After 136: the squares of 1, 3, 6 are 1, 9, 36 respectively hence the next term is 1936.
%e a(11) = a(7)*10^L(a(6)+a(10))+a(6)*10^L(a(10))+a(10)
%e = 13616164181936*10^55 + 164181936*10^46 +
%e 1641819361819361819361936193613613616164181936
%e = 136161641819361641819361641819361819361819361936193613613616164181936
%e a(100) = 1936...*10^L(a(96)+a(99))+136...*10^L(a(99))+136...936, where L(100) has approximately 2.74*10^17 digits. - _William Davidson_, Aug 15 2012
%o (Python)
%o def digits(n):
%o .d=[]
%o .while n>0:
%o ..d.append(n%10)
%o ..n=n//10
%o .return d
%o def sqdig(n):
%o .new=0
%o .num=digits(n)
%o .spacing=0
%o .while num:
%o ..k=num.pop(0)
%o ..new+=(10**(spacing))*(k**2)
%o ..if k>3:
%o ...spacing+=1
%o ..spacing+=1
%o .return new
%o def davidson(n):
%o .i=2
%o .while n>1:
%o ..i=sqdig(i)
%o ..n-=1
%o .return i
%o # _David Nacin_, Aug 19 2012
%o (Python)
%o from itertools import accumulate
%o def f(an, _): return int("".join(str(int(d)**2) for d in str(an)))
%o print(list(accumulate([2]*11, f))) # _Michael S. Branicky_, Jan 01 2022
%K nonn,easy,base
%O 1,1
%A _Amarnath Murthy_, May 13 2001
%E More terms from Larry Reeves (larryr(AT)acm.org) and _Asher Auel_, May 15 2001. Corrected by _Matthew Vandermast_, Apr 23 2003