Haskell - Factorials varis P32333


Statement
 

pdf   zip

html

Escriviu 8 funcions essencialment diferents per calcular el factorial d’un natural en Haskell. Proveu d’utilitzar recursivitat, utilitzar recursivitat final, no utilitzar recursivitat, guardes, if then else, usar map, folds, usar llistes infinites...

Especificació

Heu de definir les funcions:

fact1 :: Integer -> Integer fact2 :: Integer -> Integer fact3 :: Integer -> Integer fact4 :: Integer -> Integer fact5 :: Integer -> Integer fact6 :: Integer -> Integer fact7 :: Integer -> Integer fact8 :: Integer -> Integer
Public test cases
  • Input

    fact1 6
    fact2 6
    fact3 6
    fact4 6
    fact5 6
    fact6 6
    fact7 6
    fact8 6
    fact1 20
    

    Output

    720
    720
    720
    720
    720
    720
    720
    720
    2432902008176640000
    
  • Information
    Author
    Jordi Petit
    Language
    Catalan
    Other languages
    English
    Official solutions
    Haskell
    User solutions
    Haskell