Skip to content

Instantly share code, notes, and snippets.

@abscondment
Created November 25, 2010 07:36
Show Gist options
  • Save abscondment/715040 to your computer and use it in GitHub Desktop.
Save abscondment/715040 to your computer and use it in GitHub Desktop.
(use '(incanter core charts io latex))
(defn stirling [#^Integer n]
(* (Math/sqrt (* 2 n Math/PI))
(Math/pow n n)
(Math/pow Math/E (* -1 n))))
(defn fact [#^Integer n]
(reduce * (range 2 (inc n))))
(let [n-vals (range 5 1000)]
(view
(xy-plot n-vals
(map #(- (/ (fact %) (stirling %)) 1.0) n-vals)
:x-label "n"
:y-label "factorial(n)/stirling(n) - 1")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment