[Solved] Haskell – Finding Divisors of an Integer


I suppose the aim of the assignment is to teach you about list comprehensions, filter and similar constructs, and not to have you write functions that test for primality or create the list of divisors in any sensible way. Therefore what you need is a predicate divides,

divides :: Int -> Int -> Bool
a `divides` b = ???

Then you use that predicate for the argument to filter or in a list comprehension to find the list of divisors, and use the divisors function for your isPrime test.

0

solved Haskell – Finding Divisors of an Integer