Skip to content

Instantly share code, notes, and snippets.

@Axect
Created February 17, 2018 20:13
Show Gist options
  • Save Axect/1df51d50edfb330d3bd475aa18245b43 to your computer and use it in GitHub Desktop.
Save Axect/1df51d50edfb330d3bd475aa18245b43 to your computer and use it in GitHub Desktop.
lazy4
factors :: Integral a => a -> [a] -> [a]
factors 1 _ = []
factors m (p:ps) | m < p*p = [m]
| r==0 = p:factors q (p:ps)
| otherwise = factors m ps
where (q,r) = quotRem m p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment