From Wikipedia:

The number e is an important mathematical constant that is the base of the natural logarithm. It is approximately equal to 2.71828, and is the limit of (1 + 1/n)n as n approaches infinity.


Calculate the number e to 15 digits after the decimal point.

This means that your output must start with 2.718281828459045 or equivalent.

Your program can output digits after the required output - these may be accurate or inaccurate, inaccuracy after 15 digits does not disqualify you from the challenge. Your program may also output nothing after the required 15 digits.

This is , shortest implementation in bytes wins.


  • You may not use built in constants or hardcode the number.
  • Standard loopholes and rules apply.

Reference Implementation (Ruby)

def e(i) 
  e = 1.0                        # make it floating point
  i.times { |n|                  # loop repeats n times
    e += 1.0/(1..n+1).reduce(:*) # factorial - no factorial function
  }                              # in the Ruby standard library
  return e
e(200)                           # Almost certainly will return e
  • 4
    \$\begingroup\$ Uh, the built in constant part is a bit unclear, what if I do exp(1)? What about (-1)^(1/i*pi))? \$\endgroup\$ – FryAmTheEggman Jul 27 '16 at 18:44
  • \$\begingroup\$ You mention the lim, but then your reference uses the series sum... \$\endgroup\$ – Adám Jul 27 '16 at 18:58
  • \$\begingroup\$ Sorry, a search didn't find the previous question. \$\endgroup\$ – dkudriavtsev Jul 28 '16 at 3:03
  • \$\begingroup\$ @Adám The quote is copy pasted from Wikipedia. The article also shows the series sum formula. \$\endgroup\$ – dkudriavtsev Jul 28 '16 at 3:04
  • \$\begingroup\$ @FryAmTheEggman Use your common sense. Please don't try getting around the rules. \$\endgroup\$ – dkudriavtsev Jul 28 '16 at 3:05

Haskell, 33 31 Bytes

-2 Bytes thanks to @xnor


Straightforward implementation of the series definition. (I have posted a version of this to Reddit before.)

| improve this answer | |
  • \$\begingroup\$ You don't need parens around the product. \$\endgroup\$ – xnor Jul 27 '16 at 18:50

Haskell, 25 bytes

f 99=0;f n=1+f(n+1)/n;f 0

26 bytes:

foldr(\x y->1+y/x)0[1..99]

Not the answer you're looking for? Browse other questions tagged or ask your own question.