It's continued Pi Day - again!
Oh. My. Gawd - it’s Pi Day, again! I’ve written a few times about Pi already. No idea why this number fascinates me so much. I even made a blog post exactly 10 years ago. Unfortunately, back then I used Silverlight. Had I just used Javascript, I would still have running code.
I have also written about continued fractions once before. They are a fascinating construct which can be used to build interesting numbers. One interesting number is…Pi. You can see on wikipedia some examples for Pi expansions in the form of continued fractions.
If we take one of those and slap it into js, we get sth like this:
The steps is the input as to how far you want to go down the rabbit hole on the continued fraction.
Let’s give it a shot:
8631 was then incidentally the highest recursion depth before node on the cli would tell me… RangeError: Maximum call stack size exceeded. Checking against the number Pi as found on the internet I see that the first 12 digits after the decimal point are correct. Good enough for most calculations, I assume.
Happy Pi day everyone!