| Bytes | Lang | Time | Link |
|---|---|---|---|
| 692 | Bespoke | 250827T013546Z | Josiah W |
| 005 | Uiua | 250827T034316Z | nyxbird |
| 009 | Thunno 2 | 230817T083625Z | The Thon |
| 016 | Julia 1.0 | 221219T170145Z | MarcMush |
| 099 | C gcc | 221219T155716Z | l4m2 |
| 660 | Brainfuck 32 bit | 190412T152722Z | orthople |
| 016 | Perl 6 | 190412T172812Z | bb94 |
| 004 | Japt | 170918T092716Z | Shaggy |
| 007 | TIBASIC | 190412T161344Z | absolute |
| 014 | PHP | 180424T194644Z | Francisc |
| 016 | ><> | 180423T230643Z | Jo King |
| 865 | RPL HP48 | 171112T113019Z | Heimdall |
| 007 | MY | 170915T204031Z | Adalynn |
| 040 | Perl 5 | 170920T122314Z | primo |
| 016 | Octave | 170917T105900Z | Sanchise |
| 008 | MATL | 170917T162901Z | B. Mehta |
| 006 | APL | 170917T213644Z | Uriel |
| 130 | Desmos | 170915T052452Z | ATaco |
| 005 | Neim | 170916T141518Z | Okx |
| 005 | CJam | 170917T055124Z | Dennis |
| 269 | ForceLang | 170916T204942Z | SuperJed |
| 015 | Haskell | 170916T092353Z | jferard |
| 018 | Mathematica | 170915T224539Z | ZaMoC |
| 006 | Jelly | 170915T210006Z | Adalynn |
| 011 | 05AB1E | 170915T200848Z | Magic Oc |
| 016 | Excel VBA | 170915T204436Z | Taylor R |
| 016 | Ruby | 170915T193248Z | Snack |
| 009 | Pyth | 170915T165039Z | Mr. Xcod |
| 016 | Javascript | 170915T163144Z | Endenite |
| 017 | Math.JS | 170915T062717Z | ATaco |
| 007 | SOGL V0.12 | 170915T052930Z | dzaima |
| 015 | VBA Excel | 170915T040857Z | remoel |
| 006 | Jelly | 170915T040253Z | Jonathan |
| 008 | Charcoal | 170915T042031Z | ASCII-on |
| 016 | J | 170915T041726Z | Conor O& |
| 064 | Python 3 | 170915T041000Z | Leaky Nu |
| 009 | Jelly | 170915T033909Z | fireflam |
Bespoke, 1109 692 bytes
-417 bytes by changing from a spigot algorithm by Jeremy Gibbons to an efficient infinite series.
PUSH TRI OUTPUT N
PUT XX:FOUR SEXTET;OUTPUT CH
PUSH I
PUSH I
PUSH I
PUSH I
PUSH I
PUSH I
CONTROL DOWHILE
PUSH FOUR DO COPYN
STACKTOP PRODUCTOF
PUSH TRI DO COPYN
PUSH TRI DO COPYN
STACKTOP PRODUCTOF
STACKTOP PLUS
PUSH SEXTET DO ROT
PUSH TRI DO COPYN
STACKTOP PRODUCTOF
PUSH FIFTH DO ROT
PUSH TRI DO COPYN
STACKTOP PRODUCTOF
PUSH FOUR DO ROT
PUSH TRI DO COPYN
STACKTOP PRODUCTOF
PUSH TRI DO ROT
STACKTOP PLUSONE
DO SWITCH
PUSH BI STACKTOP PLUS
DO TURNOVER
PUSH FIFTH DO COPYN
PUT XXXX:BI TRI I TRI;STACKTOP LT
CONTROL END
DO COPY STACKTOP PLUS
PUSH BI DO COPYN
STACKTOP MODULO
PUT XX:I NUMBERZERO
PUT XXX:SEXTET DIGITNINE I;STACKTOP POW
STACKTOP PRODUCTOF
DO SWITCH
STACKTOP QUOTIENTOF
OUTPUT N
Outputs 692 digits of pi with an American decimal separator (.).
Here are the steps this program takes:
- Output
3.unconditionally. - Calculate \$n = \sum_{k=1}^{2312} k!\$ and \$d = \sum_{k=1}^{2312} (2k + 1)!!\$, the numerator and denominator of an infinite series for \$\frac{\pi}{2}\$.
- (Note: I actually end up calculating \$\frac{\pi}{2} + 3\$ because the setup is shorter, but this doesn't affect the result.)
- Output the result of \$10^{691} \times \frac{(2n)\%d}{d}\$.
It takes a while to finish, but it's not too bad. At least it finishes within the age of the universe, unlike this alternate solution...
Alternate solution, 692 542 bytes
-150 bytes by multiplying by a power of 10 before dividing and printing, instead of looping through digits one by one.
???
PUSH I
PUSH I
PUSH I
CONTROL DOWHILE
PUSH TRI DO COPYN
PUSH BI STACKTOP POW
PUSH FOUR STACKTOP PRODUCTOF
DO COPY
STACKTOP MINUSONE
PUSH TRI DO ROT
STACKTOP PRODUCTOF
PUSH TRI DO ROT
STACKTOP PRODUCTOF
PUSH TRI DO SWITCHN
STACKTOP PLUSONE
DO COPY
PUSH FOUR DO ROT
PUT XXXX:I I I I
DO COPY
STACKTOP POW
STACKTOP LT
CONTROL END
DO COPY
STACKTOP PLUS
PUSH TRI OUTPUT N
PUT XX:FOUR SEXTET;OUTPUT CH
PUSH BI DO COPYN
STACKTOP MODULO
PUT XX:I NUMBERZERO
PUT XXX:FIFTH FOUR I;STACKTOP POW
STACKTOP PRODUCTOF
DO SWITCH
STACKTOP QUOTIENTOF
OUTPUT N
Outputs 542 digits of pi with an American decimal separator (.).
This program calculates \$1111^{1111} - 1\$ iterations of the Wallis product, unconditionally outputs 3., and outputs the result of \$10^{541} \times \frac{(n \% d)}{d}\$ (where \$n\$ is the numerator and \$d\$ is the denominator). I'm pretty sure all displayed digits should be accurate, but I literally don't have the time to run it so I can check.
Uiua, 5 bytes
⁅₄÷₂τ
Try it!
÷₂ half τ tau ⁅ rounded to ₄ four decimal places.
6 bytes w/o τ
⁅₅∠0¯1
Try it!
∠ arctangent of 0 and ¯1 ⁅ rounded to ₅ five decimal places.
Thunno 2, 9 bytes
»Øȯ\œ»k6/
Compressed integer 314159265 divided by 100000000.
Thunno 2, 4 bytes
kP5ɱ
Using built-in Pi constant.
Julia 1.0, 16 bytes
show(acos(-1))##
This is the default precision printed, I sadly have to add 2 dummy characters but I don't think it's possible to make it shorter
C (gcc), 99 bytes
i;main(){for(;i<46;)printf(i++?"%02d":"3.",i[L"0;5:a]î.+& O2TÅ©']KiR J^-\N¤>cV0ý*uO"]);}
Hardcode 99 bottle of digits
Brainfuck (32 bit), 672 660 bytes
++++++[->++++++++++<]>[->+++++++++++<]>[<+>>>>>>>>++++++++++<<<<<<<-]>+++++[<+++++++++>-]+>>>>>>+[<<+++[>>[-<]<[>]<-]>>[>+>]<[<]>]>[[->>>>+<<<<]>>>+++>-]<[<<<<]<<<<<<<<+[->>>>>>>>>>>>[<+[->>>>+<<<<]>>>>>]<<<<[>>>>>[<<<<+>>>>-]<<<<<-[<<++++++++++>>-]>>>[<<[<+<<+>>>-]<[>+<-]<++<<+>>>>>>-]<<[-]<<-<[->>+<-[>>>]>[[<+>-]>+>>]<<<<<]>[-]>+<<<-[>>+<<-]<]<<<<+>>>>>>>>[-]>[<<<+>>>-]<<++++++++++<[->>+<-[>>>]>[[<+>-]>+>>]<<<<<]>[-]>+>[<<+<+>>>-]<<<<+<+>>[-[-[-[-[-[-[-[-[-<->[-<+<->>]]]]]]]]]]<[+++++[<<<++++++++<++++++++>>>>-]<<<<+<->>>>[>+<<<+++++++++<->>>-]<<<<<[>>+<<-]+<[->-<]>[>>.<<<<[+.[-]]>>-]>[>>.<<-]>[-]>[-]>>>[>>[<<<<<<<<+>>>>>>>>-]<<-]]>>[-]<<<[-]<<<<<<<<]
All credit should go to Felix Nawothnig's yapi.b.
Should you decide to downvote, please leave a comment explaining why.
Japt, 9 4 bytes
As short as it can allowably get :)
Includes an unprintable (reverse line feed, charcode 141) after the #.
3.#
In Japt, any character following # is converted to its character code and appended to any digits or decimal points which may precede it, in this case the 3.
TI-BASIC, 7 bytes
round(4tan⁻¹(1),6
round(2sin⁻¹(1),6
round(cos⁻¹(-1),6
These three statements will print 3.141593.
Note: TI-BASIC is a tokenized language. Character count does not equal byte count.
PHP, 14 Bytes
<?=acos(-001);
A bit tricky, but the precition of M_PI is 3.1415926535898
><>, 16 bytes
"]a:5;."3no>n<
There's a couple of unprintables in there, with the first having value 26 and the second 141.
RPL (HP48), 86.5 bytes, 87 digits [Does this count?]
« GROB 8 43
14159265358979323846264338327950288419716939937510582097494459230781640628620899862803
→STR 9 OVER SIZE SUB 2 "." REPL »
GROB is an image keyword. The 2 numbers that follow are width and height. The hexadecimal digits that follow are bitmap. That's 1 byte of storage for every 2 digits plus the image metadata.
Empty program « » takes 10 bytes. A command takes 2.5 bytes. A float takes 10.5 bytes, but if it's equal to a single digit integer, it can take 2.5 bytes.
HP48 stores 4 rather than 8 bits at each memory location, so a byte occupies 2 consecutive locations (low endian). Often 20-bit chunks are used, and they do take 2.5 bytes (not 3).
MY, 7 bytes
’2ō"8↑↵
How?
’, decrement the top of the stack (0is popped if empty, making the stack[-1]). (Same symbol as Jelly)2, push2.ō, since the top of the stack is two, discard the2, popn, then pushacos(n)(in radians, this gives pi, this symbol isowith a negative sign on top of it.o(for normal trig) comes from APL).", pop the top element of the stack and push it as a string.8, push8.↑, popathenb, pushb[:a](This is another symbol taken from APL).↵, output with a new line (OUTPUT <- STACK).
Perl 5, 40 bytes
}{$\=$\/~(2*$_)*~$_+2for-130..-2
Requires the command line option -pMbignum, counted as 8.
Sample Useage:
$ perl -pMbignum test.pl < /dev/null
3.141592653589793238462643383279502884197
I apologize for no TIO link, it doesn't seem to support bignum (or an unmatched opening brace...).
MATL, 9 8 bytes
-1X;V9:)
Explanation:
-1 % number literal
X; % inverse cosine (radians), giving pi
V % convert to string
9 % specify precision
:) % keep first 9 characters - 8 digits of precision
Saved one byte thanks to Luis Mendo!
Desmos, 130 bytes
f\left(\right)=\frac{\operatorname{floor}\left(10^{128}\cdot 4\sum_{k=1}^{9^9}\frac{\left(-1\right)^{k+1}}{2k-1}\right)}{10^{128}}
The source code for this (Which can be accessed by copy and pasting inside and outside of Desmos) isn't optimal when generated using the Desmos editor, so a few bytes of whitespace were golfed down where possible.
This defines a function f which takes no arguments returns pi, calculated using the Gregory Sequence to k=9^9 (I can't confirm this is accurate enough, however I am of the believe that it is, it can be made more accurate with a greater value of k) it then floors the result to 128 decimal places, which, alongside the 3., is the length of the source code.
Neim, 5 bytes
3FBρσ
Explanation:
3 Push 3
FB F pushes 45, B converts it into a character code, '.'
ρ Push 14
σ Push 15
Implicitly concatenate and print stack
ForceLang, 269 bytes
set S 0x5F258E476FC1B3B5571012206C637089460E41E814CB071E61431B5F0671F551D18D2C5D2D3A2565E408C6DE8D753F595B6E9979C3866D1C9965008DCFB02E3BD11D21DFFAF17978F05C8BBACF55A5ED5E90B1D8CAD8736AA4B728EB342B453F86353DB371D322B6A98613BC5CCB00AC2.mult 1e-270
io.write S.toString 268
Jelly, 6 bytes
-ÆAær5
Uses a different approach than the other Jelly answers.
How?
-ÆA is inverse cosine of -1 (which is pi), ær5 retrieves the needed section. It worked out so rounding is equivalent to truncation in this case
05AB1E, 11 bytes
3•∊&SK•)'.ý
COMMAND # CURRENT STACK | EXPLANATION
------------#-----------------------+-----------------------------------
3 # [3] | Push 3.
•∊&SK• # [3, 1415926535] | Push compressed base-255 number 1415926535.
) # [[3,1415926535]] | Wrap the 2 to an array.
'. # [[3,1415926535],'.'] | Push a decimal point.
ý # ['3.1415926535'] | Join 3 and 1415926535 with a decimal point.
USING BUILT-INS:
05AB1E, 4 bytes
žq5£
3žs doesn't work for some reason...
Excel VBA, 16 Bytes
Anonymous VBE immediate window functions that takes no input and output to any of Excel VBA's STDOUTs
Each line represents a separate function that returns Pi of length 16
?Mid(4*Atn(1),1)
?Str([Acos(-1)])
Debug.?4*Atn(1);
MsgBox[Acos(-1)]
[A1]="=ACOS(-1)"
Javascript, 16 bytes
_=>Math.acos(-1)
f=
_=>Math.acos(-1)
console.log(f())
Math.JS, 17 bytes.
log(-1,e).im
That's 5 leading spaces
This calculates to 15 decimal places, and implicitly prints it.
VBA (Excel), 15 bytes
MsgBox 4*Atn(1)
Output: 3.14159265358979
I think this is not acceptable as I golfed it just to fit the length of the PI. The un-golfed length of it is 17 bytes. D:
Jelly, 6 bytes
3;⁽4ƒṾ
Prints 3,14159 with the allowed "European" decimal separator, ,.
How?
3;⁽4ƒṾ - Main link: no arguments
3 - literal 3 3
⁽4ƒ - base 250 literal 14159 14159
; - concatenate [3,14159]
Ṿ - unevaluate ['3', ',', '1', '4', '1', '5', '9']
- implicit print 3,14159
Jelly, 9 bytes
“Œı⁸Ç’÷ȷ8
Outputs 3.14159265
How it Works
“Œı⁸Ç’ - The integer 314159265
÷ - divide
ȷ8 - The integer 100000000
