Calculate PI to n digits

0

There have been many questions asking for variations on how to write Pi but none are like this...

EDIT: There are many questions asking for the nth digit of Pi, I am asking for UPTO the nth digit.

The Objective: Quite simple on writing, create a programme that takes a input, I will call it n and outputs Pi to the nth digits.

Rules: Normal code golf rules apply, your code may not have Pi anywhere in it. This is so the shortest answer in bytes

Hints: It is not necessary to use this, but it may help: https://www.math.hmc.edu/funfacts/ffiles/30001.1-3.shtml where Pi/4 = 1 - 1/3 + 1/5 - 1/7 + ...

This is my first post on codegolf, so any comments on things to improve will be well appreciated.

Good luck!

Octo

Posted 2017-01-12T20:46:26.067

Reputation: 119

Question was closed 2017-01-12T20:49:39.143

Pretty sure it's a duplicate – Pavel – 2017-01-12T20:48:01.720

Of which one? I will take down if so. – Octo – 2017-01-12T20:48:20.217

That asks for the nth digit of pi. I am asking for UPTO the nth digit. – Octo – 2017-01-12T20:49:37.170

4It's not different enough IMO. To calculate the nth digit of pi, you pretty much have to calculate the digits before it. – Rɪᴋᴇʀ – 2017-01-12T20:50:13.347

http://codegolf.stackexchange.com/questions/506/calculate-500-digits-of-pi asks for 500 rather than n, but it's a trivial modification – Pavel – 2017-01-12T20:50:18.357

+Pavel ok, fair enough. – Octo – 2017-01-12T20:51:32.997

@EasterlyIrk Not necessarily. I'm not aware of any other way to do it, but that's not necessarily true. I'm not going to reopen-vote though. – HyperNeutrino – 2017-01-12T20:52:09.313

@Octo Welcome to PPCG! Use @ on this site rather than + to mention users. – HyperNeutrino – 2017-01-12T20:52:34.967

@AlexL. pretty much all the answers on the other question can easily be transferred over, so it counts as a dupe. – Rɪᴋᴇʀ – 2017-01-12T20:53:55.637

@EasterlyIrk Yeah, that's true. Most of them probably just take it as a string and find the right character. – HyperNeutrino – 2017-01-12T20:54:41.950

1

@EasterlyIrk Just as a note, these kinds of formulas do exist in general: they are called Spigot Algorithms. One does exist for pi, but it is in binary, and as far as I know you can't avoid also calculating the predigits to get the base ten values. However, requiring that the algorithm support very large n could still be sufficient to make this not a duplicate.

– FryAmTheEggman – 2017-01-13T02:04:50.150

No answers