Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
A359246
Lexicographically earliest sequence of positive numbers in which no nonempty subsequence of consecutive terms sums to a triangular number.
0
2, 2, 5, 2, 2, 5, 2, 2, 5, 2, 2, 20, 2, 7, 2, 7, 2, 14, 9, 7, 2, 7, 2, 29, 2, 7, 2, 7, 2, 7, 2, 41, 9, 9, 16, 22, 2, 23, 7, 2, 7, 2, 7, 2, 7, 22, 9, 2, 7, 2, 7, 43, 9, 29, 2, 41, 9, 7, 2, 9, 5, 2, 7, 2, 22, 9, 9, 9, 25, 9, 29, 2, 7, 2, 7, 2, 32, 43, 65, 5, 2, 2
OFFSET
0,1
COMMENTS
Differences of A030194.
EXAMPLE
a(0) = 2 by the definition of the sequence. The next number >= 2 is 2; {2, 2 + 2} are not triangular numbers, thus a(1) = 2. Then we try 2; but 2 + 2 + 2 is a triangular number. We cannot try 3, which is a triangular number, so we try 4; but 4 + 2 is a triangular number, so we try 5; {5, 5 + 2, 5 + 2 + 2} are not triangular numbers, thus a(2) = 5.
MAPLE
q:= proc(n) option remember; issqr(8*n+1) end:
s:= proc(i, j) option remember; `if`(i>j, 0, a(j)+s(i, j-1)) end:
a:= proc(n) option remember; local k; for k from 2 while
ormap(q, [k+s(i, n-1)$i=0..n]) do od; k
end: a(-1):=-1:
seq(a(n), n=0..81); # Alois P. Heinz, Jan 21 2023
MATHEMATICA
triQ[n_] := IntegerQ @ Sqrt[8*n + 1]; a[0] = 2; a[n_] := a[n] = Module[{k = 2, t = Accumulate @ Table[a[i], {i, n - 1, 0, -1}]}, While[triQ[k] || AnyTrue[t + k, triQ], k++]; k]; Array[a, 100, 0] (* Amiram Eldar, Jan 21 2023 *)
CROSSREFS
Cf. A000217, A030194 (partial sums), A332941, A360019.
Sequence in context: A155679 A319771 A021448 * A229709 A242277 A241476
KEYWORD
nonn
AUTHOR
Ctibor O. Zizka, Jan 21 2023
EXTENSIONS
More terms from Amiram Eldar, Jan 21 2023
STATUS
approved