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!

  • \$\begingroup\$ Pretty sure it's a duplicate \$\endgroup\$
    – Pavel
    Jan 12 '17 at 20:48
  • \$\begingroup\$ Of which one? I will take down if so. \$\endgroup\$
    – Octo
    Jan 12 '17 at 20:48
  • \$\begingroup\$ codegolf.stackexchange.com/questions/84444/… \$\endgroup\$
    – Pavel
    Jan 12 '17 at 20:48
  • 4
    \$\begingroup\$ It's not different enough IMO. To calculate the nth digit of pi, you pretty much have to calculate the digits before it. \$\endgroup\$
    – Riker
    Jan 12 '17 at 20:50
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ Jan 13 '17 at 2:04

Browse other questions tagged or ask your own question.