Skip to content

Instantly share code, notes, and snippets.

@t-ob
Created May 21, 2012 18:33
Show Gist options
  • Save t-ob/2763810 to your computer and use it in GitHub Desktop.
Save t-ob/2763810 to your computer and use it in GitHub Desktop.
Number of factors of (n!)^2
(defn val-p-fact [n p]
(letfn [(prime-powers [n p i]
(lazy-seq
(when (<= (Math/pow p i) n)
(cons (Math/floor (/ n (Math/pow p i)))
(prime-powers n p (inc i))))))]
(reduce + (prime-powers n p 1))))
(defn interview-street-equations [n]
(int (reduce #(mod (* %1 %2) 1000007)
1
(map #(inc (* 2 (val-p-fact n %)))
(take-while #(<= % n) (lazy-primes))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment