Skip to content

Instantly share code, notes, and snippets.

@naveensrinivasan
Created September 19, 2011 23:33
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 naveensrinivasan/1227915 to your computer and use it in GitHub Desktop.
Save naveensrinivasan/1227915 to your computer and use it in GitHub Desktop.
//perfect number
//http://4clojure.com/problem/80
let perfectnumber x =
let rec divisor x counter l=
match counter < x with
|true when x % counter < 1-> divisor x (counter + 1) (counter::l)
|true -> divisor x (counter + 1) l
|_ -> (l |> List.fold (+) 0) = x
divisor x 1 []
perfectnumber 8128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment