Last active
December 27, 2015 08:19
-
-
Save markheath/7295402 to your computer and use it in GitHub Desktop.
recursive factorization function in F#
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
let rec f n x acc = | |
if x = n then | |
x::acc | |
elif n % x = 0 then | |
f (n/x) x (x::acc) | |
else | |
f n (x+1) acc | |
let factorise n = f n 2 [] | |
let factors = factorise 124782 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment