Almkvist-Giullera formula for pi: Difference between revisions
→{{header|Common Lisp}}: Add output header.
m (→{{header|dc}}: Add output header) |
(→{{header|Common Lisp}}: Add output header.) |
||
Line 182:
(defun integral (n)
(/r (*r 32 (!r (*r 6 n)) (+r (*r 532 n n) (*r 126 n) 9)) (*r 3 (expt-r (!r n) 6))))
; the exponent for 10 in the nth term of the series
(defun power (n) (- 3 (* 6 (1+ n))))
; the nth term of the series
(defun a-g (n)
(/r (integral n) (expt-r 10 (
; the sum of the first n terms
Line 197 ⟶ 200:
(sqrt-r (/r 1 (a-g-sigma n))))
(format t "~A. ~44A~4A ~A~%" "N" "Integral part of Nth term" "×10^" "=Actual value of Nth term")
(loop for i from 0 to 9 doing
(format t "~&~a. ~44d ~3d " i (integral i) (
(finish-output *standard-output*)
(print-r (a-g i) 50 nil))
Line 206 ⟶ 210:
{{Out}}
<pre>
0. 96 -3 +0.09600000000000000000000000000000000000000000000000...
1. 5122560 -9 +0.00512256000000000000000000000000000000000000000000...
2. 190722470400 -15 +0.00019072247040000000000000000000000000000000000000...
|