| Bytes | Lang | Time | Link |
|---|---|---|---|
| 050 | APLNARS | 240911T083929Z | Rosario |
| 2329 | SageMath | 240905T121948Z | 12431234 |
| 058 | JavaScript | 240904T092553Z | Shaggy |
| 059 | Python 2 | 240904T002929Z | Lucenapo |
| 002 | Vyxal | 221106T173314Z | pacman25 |
| 012 | Perl 5 Mbignum=bexp p | 200123T221837Z | Xcali |
| 007 | Mathematica | 200123T181503Z | RGS |
| 002 | 05AB1E | 160502T071331Z | user5340 |
| nan | Mathcad | 160502T130853Z | Stuart B |
| 014 | GTB | 140202T225754Z | Timtech |
| 017 | J | 140202T224358Z | barbermo |
| 017 | bc | 140202T203653Z | Tomas |
| 069 | Python | 110313T132148Z | hallvabo |
| 020 | J | 110313T041833Z | Jesse Mi |
| 041 | GolfScript | 110313T144140Z | aaaaaaaa |
| 068 | Ruby | 110313T010850Z | david4de |
| 067 | Python | 110313T095020Z | jfs |
| 012 | Mathematica | 110313T010003Z | Quixotic |
APL(NARS), 50 chars
{(⍵+2)↑{∧/'90'∊⍨¯3↑m←{⎕FPC←7×⍵⋄⍵⍕*1v}⍵+3:∇⍵+1⋄m}⍵}
this would find at last 3 digit more than the solution because problem of round last digit. Then cut if the last part 3 digits has no "0" or "9", otherwise search increment the precision, until the last 3 digits has no "0" or "9". It seems the round problem there is only in the case last 3 digits are "999" or "000", so for brevity one can say "the last 3 digits have no 0 or 9".
h←{(⍵+2)↑{∧/'90'∊⍨¯3↑m←{⎕FPC←7×⍵⋄⍵⍕*1v}⍵+3:∇⍵+1⋄m}⍵}
h 100
2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427
h 7
2.718281
SageMath, 23 Byte (function) or 29 (using stdin and stdout)
Define a lambda function
f=lambda n: e.n(None,n)
Using stdin and stdout
print(e.n(None,int(input())))
JavaScript, 58 bytes
Adaptation of Lucenaposition's Python solution.
i=>`2.`+(g=x=>y?g(x/y--+10n**z):x+``)(y=z=999n).slice(1,i)
53 52 bytes
If we only need to return the digits.
i=>``.padEnd(i,(g=x=>y?g(x/y--+10n**z):x)(y=z=999n))
Mathematica, 7 bytes
N[E,#]&
My answer is a further golfing of this answer.
For some reason, the output over at TIO looks funny but I tested it on my machine and the code works just fine.
05AB1E, 4 3 2 bytes
Crossed out 4 is still regular 4 ;(
Thanks to @Adnan for a byte.
žt
Uses CP-1252 encoding.
Explanation:
žt - Push input. Pop a, push e to a places (up to 10000).
Update:
Remove I, as žt takes input anyway if none is on the stack.
Mathcad, [tbd] bytes
Uses a spigot algorithm - http://comjnl.oxfordjournals.org/content/11/2/229.full.pdf+html.
Byte count not given as Mathcad byte count equivalence is yet to be determined. However, using a symbol equivalence it is roughly 121 bytes ... and not going to win any brevity prizes no matter how the equivalence is determined.
GTB, 14
eS?`AS;_,1,A+1
Explanation
e - Put e as the last calculated value
S? - Convert e to string _
`A - Input A
S;_,1,A+1 Display the first A digits of e
J, 17
(":&(x:^1)@*&0j1)
Example:
(":&(x:^1)@*&0j1) 50
2.71828182845891281655718620537435347047040502245993
Uses built in exponential verb - so, "compute" is on shaky grounds. Basically:
^1 - computes e**1
x: - does extended precision
0jy ": - formats the number to y digit
bc, 17 chars
scale=read()
e(1)
Python, 69
e=f=n=1;N=input()+2;exec"e+=10**N/f;f*=n;n+=1;"*N;print'2.'+`e`[1:-4]
Computes N+2 iterations of the standard power series for e.
J, 20...ish.
Computational, but... Very inefficient. With n defined (20):
(0 j.<:n)":+/%!i.x:n+9
As a monadic function (32):
ge =. 3 : '(0 j.<:y)":+/%!i.x:y+9'
As a tacit function (33, fixed):
(0 j.<:)":(+/)&:(%&!&i.&x:&(9&+))
GolfScript 43 41
~10\?1:b 461,{)b*:b@+\}460*;*b/`);(;'2.'\
Edit: I might as well replace the 0 with the leftover 1 from initializing b, the resulting difference is far too small to make it to the output.
I left the old version as that is what I have documented below.
~10\?1:b;0 461,{)b*:b@+\}460*;*b/`);(;'2.'\
~10\? Take input and calculate 10^input, leave the result on the stack.
1:b; Store 1 in b.
0 461, Put 0 on the stack, put the array [0 1 ... 459 460] on the stack.
{ }460* Execute function 460 times.
)b*:b Take the last element of the array, multiply it by b, store result in b and leave the result on the stack.
@+\ Switch the 0 (which is only a zero at the first iteration) to the top of the stack, add it to the leftover b value, and switch the result back again.
; Remove the rest of the array (only [0] is left).
The number that was initialized to 0 now hold the value e*460! and b hold 460!
* Multiply 10^input by e*460! (they are at this point the only 2 elements left on the stack).
b/ Divide the result by b.
The stack now hold the value e*10^input which when converted to a string will hold all the decimals, but not the dot.
`);(;'2.'\ A bunch of string operations to fit in the dot.
e*460! is calculated as 1 + 460 + 460*459 + 460*459*458 etc.
Ruby, 68
require 'bigdecimal/math';include BigMath;puts E(gets.to_i).to_s 'F'
Python, 67
import decimal as d
d.getcontext().prec=input()
print d._One.exp()
Mathematica (12 bytes)
N[E,Input[]]
