Coding challenge

Write some code to set $a_0=1$, $b_0=1/\sqrt{2}$, and $s_0=1/2$, iterate with $a_k=\frac{a_{k-1}+b_{k+1}}{2}$, $b_k=\sqrt{a_{k-1}b_{k-1}}$, $c_k-a_k^2-b_k^2$, $s_k=s_{k-1}-2^kc_k$ then $p_k=\frac{2a_k^2}{s_k}$. What number does $p_k$ eventually converge to? (Ref: Borwein, p.75.)

Type your code here:


Lua reference

See your results here:

Show a friend, family member, or teacher what you've done!

Here is a share link to your code: