Haskell - Fibonacci again (1) P94014


Statement
 

pdf   zip

thehtml

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

Scoring

  • test-1:  ‍ Inputs with n≤25.  ‍10 Points ‍
  • test-2:  ‍ Inputs with n≤10000.  ‍30 Points ‍
  • test-3:  ‍ Inputs with n≤50000000.  ‍60 Points ‍
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