1

I want to calculate pi. But, I have quite a few limits. Variables can only hold up to 5 decimal places, and I only have the following operators:

Addition Subtraction Multiplication Division Exponents Square roots Sin Cos Basic Loops, Conditionals, and relational operators. 

The BBP algorithm seems useless here, because even though it would not need arbitrary precision, I cannot convert between bases. I'm not aware of any other formulas that can find the nth digit of pi in base 10. Would it even be possible to calculate pi using these constraints?

2
  • 1
    What is the precision you need? Or, do you want to compute arbitrary n'th decimal digit of pi? Commented May 8, 2016 at 0:52
  • @karakfa Arbitrary nth digit Commented May 8, 2016 at 14:05

1 Answer 1

1
+50

BBP can be modified to give π in Base 10. There's a Java implementation on Github. (I believe that the screenshot of the algorithm description is taken from Pi - Unleashed by Arndt/Haenel.)

You'll need the modulo operation and a means to calculate the closest integer to the logarithm of a number, but you can perform them using the operations you have and loops.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.