banovski

Project Euler, Problem #5, Haskell

Dec 11th, 2021 (edited)
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- The problem: 2520 is the smallest number that can be divided by
  2. -- each of the numbers from 1 to 10 without any remainder. What is the
  3. -- smallest positive number that is evenly divisible by all of the
  4. -- numbers from 1 to 20?
  5.  
  6. main :: IO ()
  7. main =
  8.   print $
  9.   head
  10.     [ x
  11.     | x <- [20,40 .. product [11 .. 20]]
  12.     , null [y | y <- [11 .. 20], mod x y /= 0]
  13.     ]
  14.  
  15. -- 232792560
  16.  
  17. -- real 0m3,226s
  18. -- user 0m3,201s
  19. -- sys  0m0,017s
Add Comment
Please, Sign In to add comment