Created
January 6, 2015 13:10
-
-
Save qrilka/70fcfd28961df3151182 to your computer and use it in GitHub Desktop.
divisors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
qrilka@qdesktop ~ $ ghci | |
GHCi, version 7.8.4: http://www.haskell.org/ghc/ :? for help | |
Loading package ghc-prim ... linking ... done. | |
Loading package integer-gmp ... linking ... done. | |
Loading package base ... linking ... done. | |
λ> let divisors1 n ds = if null subds then [n] else subd:(divisors1 (n `div` subd) (dropWhile (< subd) ds)) where subds = [i| i <- takeWhile (\x->x*x<n) ds, n `rem` i == 0];subd = head subds | |
λ> :set +s | |
λ> divisors1 93819012551 [2..] | |
[11,9539,894119] | |
(0.01 secs, 0 bytes) | |
λ> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment