Haskell - Various factorials P32333


Statement
 

pdf   zip

html

Write 8 essentially diferent functions that compute the factorial of a natural number in Haskell. You can use recursion, final recursion, no recursion, guards, if then else, map, folds, infinite lists...

Specification

You should define the following functions:

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
    English
    Translator
    Jordi Petit
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    Haskell
    User solutions
    Haskell