%I #22 Aug 16 2019 00:51:29
%S 1,2,0,0,1,4,0,1,3,0,1,3,27,0,1,4,10000,0,1,4,256,0,1,4,256
%N For n >= 1, if there exists an m < n such that a(m) = a(n), take the largest such m and set a(n+1) = (n-m)^a(n); otherwise a(n+1) = 0. Start with a(1)=1, a(2)=2.
%C This sequence quickly generates terms of immense size.
%C Changing what a(n+1) is set to when a new term arises changes the sequence nontrivially.
%t Nest[Function[{a, n}, Append[a, If[Length@ # == 0, 0, (n - #[[-1, 1]])^Last@ a] &@ Position[Most@ a, _?(# == Last@ a &)] ]] @@ {#, Length@ #} &, {1, 2}, 24] (* _Michael De Vlieger_, Jul 08 2019 *)
%o (Python)
%o def Prog(length):
%o L = 2
%o seq = [1,2]
%o while L < length:
%o x = len(seq)-1
%o while x > 0:
%o if seq[-1] == seq[x-1]:
%o m_minus_n = len(seq)-x
%o a_n = seq[L-1]
%o seq.append((m_minus_n)**a_n)
%o x = -1
%o else:
%o x -= 1
%o if x == 0:
%o seq.append(0)
%o L += 1
%o return seq
%Y Cf. A181391.
%K nonn
%O 1,2
%A _Philip Kalisman_, Jul 07 2019