Created
July 30, 2013 13:56
-
-
Save WillNess/6113118 to your computer and use it in GitHub Desktop.
divisors one-liner
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
| divs n = concat $ unfoldr (\(n,i)->case n of 1->Nothing; | |
| _->if i*i>n then Just([n], (1,i)) else case rem n i of {0->Just([i], (div n i,i) | |
| ); _->Just([], (n,i+1))}) (n,2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment