Skip to main content
2 of 2
Commonmark migration

Clojure, 253 bytes

(defmacro q[& a] `(with-precision ~@a))(defn h[n](nth(str(reduce +(map #(let[p(+(* n 2)1)a(q p(/ 1M(.pow 16M %)))b(q p(/ 4M(+(* 8 %)1)))c(q p(/ 2M(+(* 8 %)4)))d(q p(/ 1M(+(* 8 %)5)))e(q p(/ 1M(+(* 8 %)6)))](* a(-(-(- b c)d)e)))(range(+ n 9)))))(+ n 2))) 

Calculate number pi using this formula. Have to redefine macro with-precision as it's used too frequently.

You can see the output here: https://ideone.com/AzumC3 1000 and 10000 takes exceeds time limit used on ideone, shrugs

cliffroot
  • 1.1k
  • 6
  • 6