Skip to content

Instantly share code, notes, and snippets.

@markheath
Last active December 27, 2015 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markheath/7295402 to your computer and use it in GitHub Desktop.
Save markheath/7295402 to your computer and use it in GitHub Desktop.
recursive factorization function in F#
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