#!/usr/local/bin/sbcl --script

; Calculate pi on local machine (single thread)

(defvar t0 (get-universal-time))
(format t "Calculating pi on local machine (single thread).~%")
(format t "3.14159265358979323846 is the 20 decimal place target result. Please wait..~%")
(defvar tot 0)
(defvar x 0)
(dotimes (n 2400000)
  (setq x (+ x 2))
  (setq tot (+ tot (round (/ 4000000000000000000000000000000 (* x (+ x 1) (+ x 2))))))
  (setq x (+ x 2))
  (setq tot (- tot (round (/ 4000000000000000000000000000000 (* x (+ x 1) (+ x 2))))))
)
(format t "~%")
(format t "~d.~d~%" 3 tot)
(defvar t1 (get-universal-time))
(format t "~d seconds~%" (- t1 t0))
