CS 246 Programming Paradigms
Home Work #1
Due on Tuesday, January 29
Implement the following functions in IFP:
- Sum of factorials:
N : SumFac -> 0! + 1! + ... + N!
- Define the function:
N : divisors -> <n1, ,,,nk> a list of all divisors of N (i.e. each
ni divides N evenly)
Example:
show 12 : divisors -> <1, 2, 3, 4, 6, 12>
- A prime number N is a number whose only divisors are 1 and N. Using divisors
from above, write the function:
N : IsPrime -> t if N is prime, f otherwise