login
a(0)=0; for n>0, a(n) is the least positive integer that cannot be represented as Sum_{k=1..n-1} a(i_k)*a(k), with 0 <= i_k < n.
1

%I #65 May 24 2021 08:00:23

%S 0,1,2,7,24,85,285,1143,6268,216784,1059813,6100794,226303113

%N a(0)=0; for n>0, a(n) is the least positive integer that cannot be represented as Sum_{k=1..n-1} a(i_k)*a(k), with 0 <= i_k < n.

%e a(1)= 1 since it is not possible to write 1 using only a(0). a(2)=2, since it is not possible to obtain 2 using only a(0) and a(1). The following numbers up to 6 can be represented using these first 3 elements of the sequence: 3 = 1*1 + 1*2, 4 = 0*1 + 2*2, 5 = 1*1 + 2*2, 6 = 2*1 + 2*2. Again we reach a number that cannot be represented as defined above, so that number is appended to the sequence. It happens here when we try to represent 7 using only a(0)=0, a(1)=1, and a(2)=2. So 7 becomes a(3).

%e A larger example: 216752 = 1*1 + 1*2 + 85*7 + 285*24 + 85*85 + 85*285 + 24*1143 + 24*6268

%t Nest[Function[a, Append[a, 1 + LengthWhile[Differences@ #, # == 1 &] &@ Union[Total /@ Map[a # &, Tuples[a, Length@ a]]]]], {0}, 8] (* _Michael De Vlieger_, Jan 09 2018 *)

%o (Python)

%o # Generate all the elements in the sequence, S, necessary to represent all

%o # numbers until the integer 'last'. It also shows how each integer is

%o # represented by showing the sequence elements and the respective

%o # multiplicative factors.

%o import numpy as np

%o import itertools

%o last=100

%o def generate(i,S):

%o n=len(S)

%o s=np.asarray(S,dtype=np.int)

%o perms = [p for p in itertools.product(S, repeat=n)]

%o for iks in perms:

%o t=np.asarray(iks)

%o if np.dot(t,s) == i:

%o print('%d=' %i, end=',')

%o print(t,'x',s)

%o return 0

%o return -1

%o S=[0]

%o for i in range(1,last+1):

%o if generate(i,S) == -1:

%o S.append(i)

%o generate(i,S)

%K nonn,more,hard

%O 0,3

%A _Luis F.B.A. Alexandre_, Dec 28 2017

%E a(9) from _Robert G. Wilson v_, Jan 09 2018

%E a(10)-a(11) from _Jon E. Schoenfield_, Jan 16 2018

%E a(12) from _Giovanni Resta_, Jan 22 2018