CS 246 Programming Paradigms
Home Work #2
Due on Tuesday, February 12

Implement the following functions in Haskell (using the Haskell Hugs Interpreter):

  1. Sum of factorials:

    sumFac n = 0! + 1! + ... + N!

  2. Define the function:

    divisors n = [n1,..,nk] a list of all divisors of N (i.e. each ni divides N evenly)

    Example:

    divisors n = [1, 2, 3, 4, 6, 12]

  3. A prime number N is a number whose only divisors are 1 and N. Using divisors from above, write the function:

    isPrime n = t if N is prime, f otherwise