Ad
Mathematics
Algorithms
Logic
Numbers
Code
Diff
  • ;; very much a golf solution that takes advantage of the sequence characteristics
    
    (reduce + (map / (cycle [4.0 -4.0]) (range 1 1200001 2)))
    • (->> (iterate inc 0)
    • (map #(-> (Math/pow -1 %) (/ (inc (* 2 %)))))
    • (take 1200001)
    • (reduce +)
    • (* 4)
    • println)
    • ;; very much a golf solution that takes advantage of the sequence characteristics
    • (reduce + (map / (cycle [4.0 -4.0]) (range 1 1200001 2)))