Skip to main content
fix allignment
Source Link
bsoelch
  • 6k
  • 1
  • 9
  • 62

Itr, 6 bytes

1#Måâ+

takes n as input, computes the n-th Fibonacci number (0-indexed)

online interpreter

Explanation

1      ; push 1
 #M    ; for every number in the 1-based range to the input
   å   ; ignore that number
    â  ; push the top value below the 2nd value
     + ; add the top two values
       ; implicit output

Itr , 1110 bytes

Directly computes the n-th Fibonacci number using Matrix powers, sadly a bit longer than the other solution

(1ä,1)#^M¡M

takes n as input, computes the n-th Fibonacci number (1-indexed)

online interpreteronline interpreter

Explanation

(1ä,1)        ; the matrix [[1,1],[1,0]] (the opening bracket at the start can be left out)
       ^      ; to the power of
      #       ; the input
        M¡M   ; get the lower left element
        M¡    ; push the rows of the matrix reversed
          M   ; push all elements of the reversed lower row

Itr , 11 bytes

(1ä,1)#^M¡M

takes n as input, computes the n-th Fibonacci number (1-indexed)

online interpreter

Explanation

(1ä,1)        ; the matrix [[1,1],[1,0]]
       ^      ; to the power of
      #       ; the input
        M¡M   ; get the lower left element
        M¡    ; push the rows of the matrix reversed
          M   ; push all elements of the reversed lower row

Itr, 6 bytes

1#Måâ+

takes n as input, computes the n-th Fibonacci number (0-indexed)

online interpreter

Explanation

1      ; push 1
 #M    ; for every number in the 1-based range to the input
   å   ; ignore that number
    â  ; push the top value below the 2nd value
     + ; add the top two values
       ; implicit output

Itr , 10 bytes

Directly computes the n-th Fibonacci number using Matrix powers, sadly a bit longer than the other solution

1ä,1)#^M¡M

takes n as input, computes the n-th Fibonacci number (1-indexed)

online interpreter

Explanation

(1ä,1)        ; the matrix [[1,1],[1,0]] (the opening bracket at the start can be left out)
       ^      ; to the power of
      #       ; the input
        M¡M   ; get the lower left element
        M¡    ; push the rows of the matrix reversed
          M   ; push all elements of the reversed lower row
Source Link
bsoelch
  • 6k
  • 1
  • 9
  • 62

Itr , 11 bytes

(1ä,1)#^M¡M

takes n as input, computes the n-th Fibonacci number (1-indexed)

online interpreter

Explanation

(1ä,1)        ; the matrix [[1,1],[1,0]]
       ^      ; to the power of
      #       ; the input
        M¡M   ; get the lower left element
        M¡    ; push the rows of the matrix reversed
          M   ; push all elements of the reversed lower row