Haskell - Fibonacci again (1) P94014


Statement
 

pdf   zip

Write a function fib :: Int -> Integer that, given a natural nn, returns the nn-th element of the Fibonacci sequence.

Scoring

  • test-1:   Inputs with n25n\le 25.

  • test-2:   Inputs with n10000n\le 10000.

  • test-3:   Inputs with n50000000n\le 50000000.

Public test cases
  • Input

    map fib [0..8]
    

    Output

    [0,1,1,2,3,5,8,13,21]
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Jordi Petit
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    Haskell
    User solutions
    Haskell