If you cannot read and write a trivial math equation as code then I really question how you got here. That formulation for approximation of irrationals is one of the reasons computers exist! If you can't do this, go into a cave on a mountaintop behind a waterfall in a hidden vale and proceed to train until you can. It's not an unreasonable or un-useful thing.
Of course, it's actually trickier than you might think on modern computers if you go out much further than 10 decimal places or so.
Of course, it's actually trickier than you might think on modern computers if you go out much further than 10 decimal places or so.