New Order #5: where Fibonacci and Beatty meet at Wythoff

R, 143 130 124 123 bytes

for(i in k)m=m~m[i,]+m[i+1,]

Try it online!

Uses the formula \$T(n,-1)=n-1; T(n,0)=\lfloor n\cdot\phi\rfloor;T(n,k)=T(n,k-1)+T(n,k-2)\$ to construct the array (transposed), then splits the array along antidiagonals. k merely exists to prevent forcing a drop=F argument in m[-1:-2,] for the case n=1.

Thanks to Neil for pointing out a 1 byte golf.

R, 150 138 132 bytes

for(j in 2:n-1)T=c(T,T[j]+T[j+1])

Try it online!

Implements the formula \$T(n,k)=Fib(k+1)\cdot\lfloor n\cdot\phi\rfloor+Fib(k)\cdot(n-1)\$ to get generate the array, then splits along the antidiagonals and extracts the nth element.

Thanks to Robin Ryder for the T[2]=1 trick for generating the Fibonacci sequence.

Both solutions are highly inefficient, creating an nxn matrix of (most likely) doubles, as R promotes integer (32-bit signed) to double automatically when overflowing, but the second one should be quite a lot faster. Taking n as a bignum should work automatically, using the call gmp::as.bigz(n), should loss of precision under doubles be worrisome, and then the language would be R + gmp.

Jelly, 27 24 bytes


Try it online!

Monadic link using 1-based indexing. Thanks to @JonathanAllan for a better way of getting the row and columns from n and saving 3 bytes. In its shortest form it’s too slow for larger n on TIO, so the following Try it online! reduces the size of the initial list of rows and columns at the cost of three bytes.


p`                       | Cartesian product of the range from 1..input with itself   
  SÞ                     | Sort by sum
    ⁸ị                   | Find the tuple at the position indicated by the input - this is the row and column
      ð               ð/ | Start a new dyadic chain using the row as the left and column as the right argument
       ’                 | Increase the row by 1
        ;    ¥           | Concatenate to:
         ×Øp             |   row × φ
            Ḟ            |   rounded down
              ×     ¤    | Multiply this pair by
                  ÆḞ     |   the Fibonacci numbers at positions
               ⁹         |   column index and
                r‘       |   column index plus one
                     S   | sum

Note this is based on the description of the Python code on the OEIS page.

Wolfram Language (Mathematica), 90 bytes


Try it online!