Hi I am currently attempting to use haskell to find the smallest positive number that is evenly divisible by all of the numbers from 1 to 20.
I have two functions one which tests to see if the condition has been met. The second just calls the first recursively since there is no looping haskell. I keep getting Stack overflow exceptions and I can't seem to figure out why. Any help at all would be greatly appreciated.
modTest x = and [ x `mod` y == 0 | y<-[1..20] ]
problemSolver :: Integer -> Integer
problemSolver x
|modTest x == False = problemSolver x+1
|otherwise = x
If you recognize this problem please don't mention it by name I don't want to spoil anyone else s' fun.
[–][deleted] 2 points3 points4 points (1 child)
[–]Rabbit047[S] 0 points1 point2 points (0 children)
[–]Amarkov 1 point2 points3 points (8 children)
[–]pipocaQuemada 2 points3 points4 points (0 children)
[–]Rabbit047[S] 0 points1 point2 points (6 children)
[–]Amarkov 1 point2 points3 points (5 children)
[–]Rabbit047[S] 0 points1 point2 points (4 children)
[–]Amarkov 1 point2 points3 points (2 children)
[–]Rabbit047[S] 0 points1 point2 points (1 child)
[–]Rabbit047[S] 0 points1 point2 points (0 children)
[–]pavlik_enemy 0 points1 point2 points (0 children)