Almkvist-Giullera formula for pi: Difference between revisions
Content added Content deleted
(J version) |
m (→{{header|J}}) |
||
Line 673: | Line 673: | ||
This solution just has it hard-coded that 53 iterations is necessary for 70 decimals. It would be possible to write a loop with a test, though in practice it would also be acceptable to just experiment to find the number of iterations. |
This solution just has it hard-coded that 53 iterations is necessary for 70 decimals. It would be possible to write a loop with a test, though in practice it would also be acceptable to just experiment to find the number of iterations. |
||
sqrt is noticeably slow, |
sqrt is noticeably slow, bringing execution time to over 1 second. I'm not sure if it's because it's coded imperatively using traditional loops vs. J point-free style, or if it's due to the fact that the numbers are very large. I suspect the latter since it only takes 4 iterations of Heron's method to get the square root. |
||
<lang J> |
<lang J> |
||
numerator =: monad define "0 |
numerator =: monad define "0 |
||
Line 725: | Line 725: | ||
pi to 70 decimals: 3.1415926535897932384626433832795028841971693993751058209749445923078164 |
pi to 70 decimals: 3.1415926535897932384626433832795028841971693993751058209749445923078164 |
||
</pre> |
</pre> |
||
=={{header|JavaScript}}== |
=={{header|JavaScript}}== |
||
{{trans|Common Lisp}} |
{{trans|Common Lisp}} |