[Question]
  [
We all know that the [Euler's number](//en.wikipedia.org/wiki/E_(mathematical_constant)), denoted by \$e\$, to the power of some variable \$x\$, can be approximated by using the [Maclaurin Series](http://mathworld.wolfram.com/MaclaurinSeries.html) expansion:
$$e^x=\sum\_{k=0}^{\infty}{\frac{x^k}{k!}}=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+\dots$$
By letting \$x\$ equal \$1\$, we obtain
$$\sum\_{k=0}^{\infty}{\frac{1}{k!}{=\frac{1}{0!}+\frac{1}{1!}+\frac{1}{2!}+\frac{1}{3!}+\frac{1}{4!}+\dots\\=1+1+\frac{1}{2}+\frac{1}{6}+\frac{1}{24}+\dots}}$$
## Challenge
Write a program in any language which approximates Euler's number by taking in an input \$n\$ and calculates the series to the \$n\$th term. Note that the first term has denominator \$0!\$, not \$1!\$, i.e. \$n=1\$ corresponds to \$\frac{1}{0!}\$.
## Scoring
Program with least amount of bytes wins.
  
[Answer]
# [Wistful-C](https://github.com/Nazek42/wistful-c) - 336 bytes
My first real wistful- program! There is actually a little golfing I did, with using `someday` instead of `wait for` because the first had a shorter length.
```
if only <stdio.h> were included...
if only int f were 1...
if only int N were 0...
wish for "%d",&N upon a star
if only int i were 0...
if only double e were 0...
someday i will be N...
        if only e were e+1./f...
        if only i were i+1...
        if only f were f*i...
*sigh*
wish "%f\n",e upon a star
if wishes were horses...
```
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), 5 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
R’!İS
```
[Try it online!](http://jelly.tryitonline.net/#code=UuKAmSHEsFM&input=&args=MjA)
### How it works
```
R’!İS  Main link. Argument: n
R      Yield the range [1, ..., n].
 ’     Map decrement over the list.
  !    Map factorial over the list.
   İ   Map inverse over the list.
    S  Compute the sum.
```
[Answer]
## Pyth, ~~7~~ 6 bytes
```
smc1.!
```
[Try it here.](https://pyth.herokuapp.com/?code=smc1.%21&input=100&debug=0)
```
 m      map over range 0..input:
    .!  factorial
  c1    1 / ^
s       sum
```
Thanks to [FryAmTheEggman](https://codegolf.stackexchange.com/users/31625/fryamtheeggman) for a byte!
[Answer]
# TI-84 BASIC, 12 15 14
```
Input N
Σ(A!⁻¹,A,0,N
```
TI is a tokenized language ([bytes are counted via tokens](http://meta.codegolf.stackexchange.com/questions/1541/how-to-score-ti-basic), not individual characters).
[Answer]
# [Julia 0.6](http://julialang.org/), ~~28~~ ~~27~~ 21 bytes
```
n->sum(1./gamma(1:n))
```
[Try it online!](https://tio.run/##yyrNyUw0@59m@z9P1664NFfDUE8/PTE3N1HD0CpPU/N/Wn6RQqaCrYKhlaEBlwIQFBRl5pXk5GmkaWRqanKl5qX8BwA "Julia 0.6 – Try It Online")
This is an anonymous function that accepts an integer and returns a float. To call it, assign it to a variable.
The approach is quite straightforward. We `sum` 1 divided by the gamma function evaluated at each of 1 through *n*. This takes advantage of the property *n*! = Γ(*n*+1).
Saved 1 byte thanks to Dennis and 6 thanks to Glen O!
[Answer]
## Python, 36 bytes
**Python 2:**
```
f=lambda n,i=1:n/i and 1.+f(n,i+1)/i
```
**Python 3:**
```
f=lambda n,i=1:i<=n and 1+f(n,i+1)/i
```
[Answer]
# dc, 43 bytes
```
[d1-d1<f*]sf[dlfx1r/r1-d1<e+]se1?dk1-d1<e+p
```
This is a fairly direct translation of the series. I tried to be cleverer, but that resulted in longer code.
## Explanation
```
[d1-d1<f*]sf
```
A simple factorial function, for n>0
```
[dlfx1r/r1-d1<e+]se
```
Execute the factorial for n,...,1; invert and sum
```
1?dk1-
```
Prime the stack with 1; accept input and set an appropriate precision
```
d1<e+
```
If input was 0 or 1, we can just pass it on, else compute the partial sum.
```
p
```
Print the result.
## Test results
The first 100 expansions:
```
0
1
2
2.500
2.6666
2.70832
2.716665
2.7180553
2.71825394
2.718278766
2.7182815251
2.71828180110
2.718281826194
2.7182818282857
2.71828182844671
2.718281828458223
2.7182818284589936
2.71828182845904216
2.718281828459045062
2.7182818284590452257
2.71828182845904523484
2.718281828459045235331
2.7182818284590452353584
2.71828182845904523536012
2.718281828459045235360273
2.7182818284590452353602862
2.71828182845904523536028736
2.718281828459045235360287457
2.7182818284590452353602874700
2.71828182845904523536028747123
2.718281828459045235360287471339
2.7182818284590452353602874713514
2.71828182845904523536028747135253
2.718281828459045235360287471352649
2.7182818284590452353602874713526606
2.71828182845904523536028747135266232
2.718281828459045235360287471352662481
2.7182818284590452353602874713526624964
2.71828182845904523536028747135266249759
2.718281828459045235360287471352662497738
2.7182818284590452353602874713526624977552
2.71828182845904523536028747135266249775705
2.718281828459045235360287471352662497757231
2.7182818284590452353602874713526624977572453
2.71828182845904523536028747135266249775724691
2.718281828459045235360287471352662497757247074
2.7182818284590452353602874713526624977572470919
2.71828182845904523536028747135266249775724709352
2.718281828459045235360287471352662497757247093683
2.7182818284590452353602874713526624977572470936984
2.71828182845904523536028747135266249775724709369978
2.718281828459045235360287471352662497757247093699940
2.7182818284590452353602874713526624977572470936999574
2.71828182845904523536028747135266249775724709369995936
2.718281828459045235360287471352662497757247093699959554
2.7182818284590452353602874713526624977572470936999595729
2.71828182845904523536028747135266249775724709369995957475
2.718281828459045235360287471352662497757247093699959574944
2.7182818284590452353602874713526624977572470936999595749646
2.71828182845904523536028747135266249775724709369995957496673
2.718281828459045235360287471352662497757247093699959574966943
2.7182818284590452353602874713526624977572470936999595749669652
2.71828182845904523536028747135266249775724709369995957496696740
2.718281828459045235360287471352662497757247093699959574966967601
2.7182818284590452353602874713526624977572470936999595749669676254
2.71828182845904523536028747135266249775724709369995957496696762747
2.718281828459045235360287471352662497757247093699959574966967627699
2.7182818284590452353602874713526624977572470936999595749669676277220
2.71828182845904523536028747135266249775724709369995957496696762772386
2.718281828459045235360287471352662497757247093699959574966967627724050
2.7182818284590452353602874713526624977572470936999595749669676277240739
2.71828182845904523536028747135266249775724709369995957496696762772407632
2.718281828459045235360287471352662497757247093699959574966967627724076601
2.7182818284590452353602874713526624977572470936999595749669676277240766277
2.71828182845904523536028747135266249775724709369995957496696762772407663006
2.718281828459045235360287471352662497757247093699959574966967627724076630325
2.7182818284590452353602874713526624977572470936999595749669676277240766303508
2.71828182845904523536028747135266249775724709369995957496696762772407663035328
2.718281828459045235360287471352662497757247093699959574966967627724076630353518
2.7182818284590452353602874713526624977572470936999595749669676277240766303535449
2.71828182845904523536028747135266249775724709369995957496696762772407663035354729
2.718281828459045235360287471352662497757247093699959574966967627724076630353547565
2.7182818284590452353602874713526624977572470936999595749669676277240766303535475915
2.71828182845904523536028747135266249775724709369995957496696762772407663035354759429
2.718281828459045235360287471352662497757247093699959574966967627724076630353547594542
2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945681
2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457111
2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571352
2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713792
2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138185
2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382143
2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821752
2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217826
2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178492
2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785218
2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852481
2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525131
2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251635
2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516607
2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166394
```
Using 1000 terms:
```
2.7182818284590452353602874713526624977572470936999595749669676277240\
766303535475945713821785251664274274663919320030599218174135966290435\
729003342952605956307381323286279434907632338298807531952510190115738\
341879307021540891499348841675092447614606680822648001684774118537423\
454424371075390777449920695517027618386062613313845830007520449338265\
602976067371132007093287091274437470472306969772093101416928368190255\
151086574637721112523897844250569536967707854499699679468644549059879\
316368892300987931277361782154249992295763514822082698951936680331825\
288693984964651058209392398294887933203625094431173012381970684161403\
970198376793206832823764648042953118023287825098194558153017567173613\
320698112509961818815930416903515988885193458072738667385894228792284\
998920868058257492796104841984443634632449684875602336248270419786232\
090021609902353043699418491463140934317381436405462531520961836908887\
070167683964243781405927145635490613031072085103837505101157477041718\
986106873969655212671546889570350116
```
[Answer]
# J, 10 bytes
```
[:+/%@!@i.
```
Straight-forward approach.
## Explanation
```
[:+/%@!@i.    Input: n
        i.    Creates the range [0, 1, ..., n-1]
      !@      Maps factorial to each
    %@        Map 1/x to each
[:+/          Take the sum of the values and return it
```
[Answer]
# CJam, 11
```
r~,:m!Wf#:+
```
or
```
r~{m!W#}%:+
```
Try it online: [first version](http://cjam.aditsu.net/#code=r%7E%2C%3Am!Wf%23%3A%2B&input=7) and [second version](http://cjam.aditsu.net/#code=r%7E%7Bm!W%23%7D%25%3A%2B&input=7)
**Explanation:**
`r~` = read and evaluate  
`m!` = factorial  
`W#` = raise to the -1 power (`W` = -1)  
`:+` = sum of array  
First version constructs the [0…N-1] array and applies factorial and inverse to all its elements; 2nd version does factorial and inverse for each number then puts them in an array.
[Answer]
# JavaScript ES6, ~~44 42~~ 40
```
n=>{for(k=s=m=1;m<n;s+=k/=m++);return s}
```
An unnamed function now.
Thanks for saving 2 bytes @AlexA and thanks to @LeakyNun for another 2 bytes!
[Answer]
# MATL, ~~11~~ 7 bytes
```
:Ygl_^s
```
*4 bytes saved thanks to @Luis's recommendation to use `gamma` (`Yg`)*
[**Try it Online**](http://matl.tryitonline.net/#code=OllnbF9ecw&input=MTAw)
**Explanation**
```
        % Implicitly grab input (N)
:       % Create an array from 1...N
Yg      % Compute factorial(x-1) for each element (x) in the array
l_^     % Take the inverse
s       % Sum all elements
        % Implicitly display the result
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 6 bytes
```
q_t1Zh
```
This computes the sum using the [hypergeometric function](https://en.wikipedia.org/wiki/Hypergeometric_function) 1*F*1(*a*;*b*;*z*):
[![enter image description here](https://i.stack.imgur.com/G1aYq.gif)](https://i.stack.imgur.com/G1aYq.gif)
Works on Octave and on the online compiler, but not on Matlab, due to [a difference](https://math.stackexchange.com/q/1822112/91216) in how the hypergeometric function is defined (which will be corrected).
[**Try it online!**](http://matl.tryitonline.net/#code=cV90MVpo&input=NQ)
### Explanation
```
q_    % Take N implicitly. Compute -N+1
t     % Duplicate
1     % Push 1
Zh    % Hypergeometric function 1F1(-N+1;-N+1;1). Implicitly display
```
[Answer]
# C, 249 bytes
```
#include <stdio.h>
#include <stdlib.h>
#define z double
z f(z x){z r=1;z n=1;while(x>0){r*=n;n++;x--;}return r;}int main(int argc, char **argv){z e=0;z p=0;z d=0;p=strtod(argv[1],NULL);while(p>0){e+=1.0d/f(d);printf("%.10f\n",e);p--;d++;}return 0;}
```
Ungolfed:
```
/* approximate e */
#include <stdio.h>
#include <stdlib.h>
double fact(double x){
    double result = 1;
    double num = 1;
    while (x > 0){
        result *= num;
        num++;
        x--;
    }
    return result;
}
int main(int argc, char **argv){
    double e = 0;
    double precision = 0;
    double denom = 0;
    precision = strtod(argv[1], NULL);
    while (precision > 0){
        e += 1.0d / fact(denom);
        printf("%.10f\n", e);
        precision--;
        denom++;
    }
    return 0;
}
```
Takes a number as an argument to determine number of iterations.
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 5 bytes
```
⍳⊥⊢÷!
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/x/1bn7UtfRR16LD2xX/pwGFHvX2QWS7mg@tN37UNhHICw5yBpIhHp7B/9MOrVAwVDBSMFYwUTBVMAMA "APL (Dyalog Unicode) – Try It Online")
Using the mixed base trick found in [my answer](https://codegolf.stackexchange.com/a/194817/78410) of [another challenge](https://codegolf.stackexchange.com/q/194801/78410). Uses `⎕IO←0`.
### How it works
```
⍳⊥⊢÷!  Right argument: n, the number of terms
  ⊢÷!  v: 1÷(n-1)!
⍳      B: The array of 0 .. n-1
 ⊥     Expand v to length-n array V,
       then mixed base conversion of V in base B
Base | Digit | Value
--------------------
0    | v     | v×(1×2×..×(n-1)) = 1÷0!
1    | v     | v×(2×3×..×(n-1)) = 1÷1!
2    | v     | v×(3×..×(n-1))   = 1÷2!
..   | ..    | ..
n-2  | v     | v×(n-1)          = 1÷(n-2)!
n-1  | v     | v                = 1÷(n-1)!
```
[Answer]
# k (13 bytes)
Subject to overflows for `N>20`
```
{+/%*\1,1+!x}
```
[Answer]
## 05AB1E, 6 bytes
```
$L<!/O
```
**Explained**
```
$           # push 1 and input: N = 5
 L<         # range [0..N-1]: [0,1,2,3,4]
   !        # factorial over range [1,1,2,6,24]
    /       # divide 1/range: [1.0, 1.0, 0.5, 0.16666666666666666, 0.041666666666666664]
     O      # sum: 2.708333333333333
```
[Try it online](http://05ab1e.tryitonline.net/#code=JEw8IS9P&input=NQ)
[Answer]
## Pyke, 10 bytes
```
FSBQi^R/)s
```
[Try it here!](http://pyke.catbus.co.uk/?code=FSBQi%5ER%2F%29s&input=2%0A10)
Or 8 bytes if power=1
```
FSB1R/)s
```
[Try it here!](http://pyke.catbus.co.uk/?code=FSB1R%2F%29s&input=10)
[Answer]
## JavaScript (ES6), 28 bytes
```
f=(n,i=1)=>n&&1+f(n-1,i+1)/i
```
[Answer]
# [Dyalog APL](http://goo.gl/9KrKoM), 6 [bytes](http://meta.codegolf.stackexchange.com/a/9429/43319)
```
+/÷!⍳⎕
```
`+/` sum of  
`÷` the reciprocals of  
`!` the factorials of  
`⍳` the numbers from 0 to  
`⎕` numerical input
Assumes `⎕IO←0`, which is default on many systems.
[TryAPL](http://tryapl.org/?a=%u2395IO%u21900%20%u22C4%20%u2395PP%u219017%20%u22C4%20+/%F7%21%u237318&run)!
[Answer]
## Haskell, 37 bytes
```
((scanl(+)0$(1/)<$>scanl(*)1[1..])!!)
```
Not the shortest, but arguably the prettiest.
---
Also courtesy of [Laikoni](https://codegolf.stackexchange.com/users/56433/laikoni), here is a solution that is **2 bytes** shorter:
```
sum.(`take`((1/)<$>scanl(*)1[1..]))
```
---
```
λ> let f = ((scanl (+) 0 $ (1/) <$> scanl (*) 1 [1..]) !!)
λ> map f [1..5]
[1.0,2.0,2.5,2.6666666666666665,2.708333333333333]
λ> f 10
2.7182815255731922
λ> f 100
2.7182818284590455
λ> log (f 10)
0.9999998885745155
λ> log (f 100)
1.0
```
[Answer]
# [jq](https://stedolan.github.io/jq/), 25 bytes
```
[range(.)+1|1/tgamma]|add
```
[Try it online!](https://tio.run/##yyr8/z@6KDEvPVVDT1PbsMZQvyQ9MTc3MbYmMSXl/38zAA "jq – Try It Online")
jq currently only has IEEE754 double-precision (64-bit) floating point number support, luckily it works in its favour here.
[Answer]
# [Raku](http://raku.org/), ~~21~~ 19 bytes
```
{1+sum [\/] 1..^$_}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/2lC7uDRXITpGP1bBUE8vTiW@9n9xYqWCkkq8gq2dQnWaAlBESSEtvwgkbWjwHwA "Perl 6 – Try It Online")
*-2 bytes thanks to Jo King*
`[\/]` performs a "triangular reduction" (or "scan") using the division operator over the sequence `1, 2, ..., $_-1` (where `$_` is the argument to the function). So for example `[\/] 1..4` is the sequence `1`, `1/2`, `1/2/3`, `1/2/3/4`, which are the terms required for the `n = 5` case.
[Answer]
## Actually, 6 bytes
```
r♂!♂ìΣ
```
[Try it online!](http://actually.tryitonline.net/#code=cuKZgiHimYLDrM6j&input=Nw)
Explanation:
```
r♂!♂ìΣ
r       range(N) ([0, N-1])
 ♂!     factorial of each element
   ♂ì   reciprocal of each element
     Σ  sum
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 18 bytes
```
:1-:0r:ef:$!a:/a+.
```
### Explanation
```
:1-                 Subtract 1 from Input
   :0r              Create the list [0, Input - 1]
      :ef           Find all integers between 0 and Input - 1
         :$!a       Apply factorial to each member of that list
             :/a    Apply inverse to each element of that list
                +.  Unify the output with the sum of the list
```
[Answer]
# Maple, 18
```
add(1/i!,i=0..n-1)
```
Usage:
```
> f:=n->add(1/i!,i=0..n-1);
> f(1);
  1
> f(4);
  8/3
```
[Answer]
# C, 69 bytes
```
double f(int n){double s=1,f=1;for(int i=0;i++<n;s+=f)f/=i;return s;}
```
[Ideone it!](http://ideone.com/MnPt3U)
[Answer]
# Java with [Ten Foot Laser Pole](https://github.com/SuperJedi224/Ten-Foot-Laser-Pole), ~~238~~ 236 bytes
```
import sj224.tflp.math.*;interface U{static void main(String[]a){BigRational r=null,s,t;r=s=t=r.ONE;for(int n=new java.util.Scanner(System.in).nextInt()-1;n-->0;){t=t.multiply(r);s=s.add(t.pow(-1));r=r.add(r.ONE);}System.out.print(s);}}
```
Has much better overflow resistance than most of the other answers. For 100 terms, the result is
```
31710869445015912176908843526535027555643447320787267779096898248431156738548305814867560678144006224158425966541000436701189187481211772088720561290395499/11665776930493019085212404857033337561339496033047702683574120486902199999153739451117682997019564785781712240103402969781398151364608000000000000000000000
```
[Answer]
# [Julia 0.6](http://julialang.org/), 28 bytes
```
~k=k<1?1:1/gamma(k+1)+~(k-1)
```
[Try it online!](https://tio.run/##yyrNyUw0@/@/Lts228bQ3tDKUD89MTc3USNb21BTu04jW9dQ839BUWZeSU6enoZenYaBlZGBpuZ/AA "Julia 0.6 – Try It Online")
## Explanation
```
~k=                    #Define ~ to be
    k<1                #If k is less than 1
        ?1             #to be one
        :1/gamma(k+1)  #else add the reciprocal factorial to 
            +~(k-1)    #the function applied to the predecessor value
```
`gamma(k+1)` is equal to `factorial(k)` for positive integer inputs, and generalizes it for all values other than the nonnegative integers. It saves one byte, so why not use it?
[Answer]
# [PowerShell Core](https://github.com/PowerShell/PowerShell), ~~51~~ 43 bytes
```
param($a)++$p..$a-ge1|%{$s+=$p/=$_}
$s+!!$a
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNydFNzi9K/f@/ILEoMVdDJVFTW1ulQE9PJVE3PdWwRrVapVjbVqVA31YlvpYLyFZUVEn8//@/AQA "PowerShell Core – Try It Online")
-6 bytes thanks to *mazzy*!
-2 bytes thanks to *Zaelin Goodman*!
[Answer]
# [Thunno 2](https://github.com/Thunno/Thunno2) `S`, 3 [bytes](https://github.com/Thunno/Thunno2/blob/main/docs/codepage.md)
```
LwỊ
```
[Try it online!](https://Not-Thonnu.github.io/run?header=&code=Lw%E1%BB%8A&footer=&input=20&flags=S)
#### Explanation
```
LwỊ  # Implicit input
L    # Lowered range
 w   # Factorial
  Ị  # Reciprocal
     # Sum
     # Implicit output
```
]