Just starting with Haskell, and I put together this ugly piece to determine the numbers in a list divisible by a number and all numbers less than it.
divis :: (Integral a) => a -> [a] -> [a]
divis _ [] = []
divis n (x:xs)
| x `mod` n == 0 && n == 2 = x : divis n xs
| x `mod` n == 0 = divis (n-1) [x] ++ divis n xs
| otherwise = divis n xs
and I can call it like...
head (divis 10 [1..])
to get the first number in the list, in this case 2520. However, it seems that this is not good enough to efficently solve using a higher number like 20.
How can I fix this raskell of a haskell?
O(n^3)or so...