title: generating pi to nth digit java
body: <p>I wanted to know how I can generate pi to the nth digit. I have a couple of basic ideas.</p>
  
  <ol>
  <li>Use <code>Math.PI</code> and increase the precision (if that's possible)</li>
  <li>Use Euler's formula to generate pi but even here, I would need to increase the precision (I think)
  <img src="https://i.stack.imgur.com/AfMsO.png" alt="Euler&#39;s formula for PI"></li>
  <li>There is also Srinivasa Ramanujan's formula for generating PI which is known for it's rapid convergence. This formula seems difficult to implement. I believe, I would have to also increase deicmal precision here.<br>
  <img src="https://i.stack.imgur.com/UkXAN.png" alt="enter image description here"></li>
  </ol>
  
  <p>So in short, either way, I would need to increase the precision of <code>BigDecimal</code> depending on what the nth digit is. How would I go about increasing the precision of <code>BigDecimal</code> to nth digit? Also, if there is a better and faster of doing this, can you please point me in the correct direction.</p>
  
  <p>EDIT: I just want to generate PI. I don't want to use for calculations. and this is a question about how I can use BigDecimal to implement my ideas of generating PI.</p>