I've been struggling with this for over half an hour. I know it's something simple, but I am awful at types in Haskell, and even after reading the accepted answers to problems very similar to mine, I still cannot solve my problem - let alone understand it!
The code:
p108 = [filter (\[a,b] -> a>0 && b>0) (diophantinepairs n) | n <- [1..]]
diophantinepairs :: Integer -> [[Integer]]
diophantinepairs n = nub$map sort b
where
a = divisors n
b = [[(n-d), n - (n^2)/d] | d <- a]
The error :
249:39: No instance for (Fractional Integer) arising from a use of `/' Possible fix: add an instance declaration for (Fractional Integer) In the second argument of `(-)', namely `(n ^ 2) / d' In the expression: n - (n ^ 2) / d In the expression: [(n - d), n - (n ^ 2) / d]
Thanks, Sam.