Tribonacci sequence

A simplistic puzzle from The Riddler when applying brute force:

A Tribonacci sequence is based on three entry integers a ≤ b ≤ c, and subsequent terms are the sum of the previous three. Among Tribonacci sequences containing 2023, which one achieves the smallest fourth term, a+b+c ?

The R code

for(a in 1:m)
  for(b in a:m)
    for(e in b:m)

leads to (1,1,6) as the solution… Incidentally, this short exercise led me to finally look for a fix to entering vectors as arguments of functions requesting lists:"tri",as.list(sol[2023,]))

3 Responses to “Tribonacci sequence”

  1. Note that if you remove the a\leq b\leq c constraint, you can get the solution (4, 1, 1), which coincides with your (1, 1, 6) solution at the next step.

    You can also push further back, and end up with negative integers (which don’t seem disallowed!). For example, starting with (-23, 3, 14) gives you -6 as the 4th value. You can get an arbitrarily low negative integer: (-90, -50, 91) gives -49, and eventually get to (1, 1, 6).

  2. João Neto Says:

    I suppose the entry (-2023,0,2023) also counts since the problem does not seem to ask for positive integer numbers.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: