Calculating the value of e

From Rosetta Code
Revision as of 03:43, 21 April 2018 by CalmoSoft (talk | contribs) (Created page with "{{Calculating the value of e}} Calculate the value of e. See details: [https://en.wikipedia.org/wiki/E_(mathematical_constant) Calculating the value of e] =={{header|Ring}}=...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:Calculating the value of e

Calculate the value of e. See details: Calculating the value of e

Ring

<lang ring>

  1. Project : Calculating the value of e
  2. Date  : 2018/04/21
  3. Author : Gal Zsolt [~ CalmoSoft ~]
  4. Email  : <calmosoft@gmail.com>

decimals(14)

for n = 1 to 100000

    e = pow((1 + 1/n),n)

next see "Calculating the value of e with method #1:" + nl see "e = " + e + nl

e = 0 for n = 0 to 12

    e = e + (1 / factorial(n))

next see "Calculating the value of e with method #2:" + nl see "e = " + e + nl

func factorial(n)

      if n = 0 or n = 1 
         return 1 
      else
         return n * factorial(n-1)
      ok

</lang> Output:

Calculating the value of e with method #1:
e = 2.71826823719230
Calculating the value of e with method #2:
e = 2.71828182828617