Euler’s Number

The number e is a famous irrational number called Euler’s number after Leonhard Euler a Swiss Mathematician (1707 – 1783). Number e is considered to be one of the most important numbers in mathematics.

The first few digits are: 2.7182818284590452353602874713527… It has an infinite number of digits with no recurring pattern. It cannot be written as a simple fraction.

Number e is the limit of (1 + 1/n)n as n approaches infinity:
euler-expression

Number e is a mathematical constant that is the base of the natural logarithm: the unique number whose natural logarithm is equal to one. Find out more on https://en.wikipedia.org/wiki/E_(mathematical_constant).

In this challenge we will use a Python script to calculate an approximation of e using two different approaches:

  • An iterative approach
  • A recursive approach

Calculating e using an iterative approach


Euler’s number, e, can also be calculated as the sum of the infinite series:

euler-infinite-series

Complete your Python script to implement this infinite series using an iterative approach. (Method 2)

Calculating e using a recursive approach


A less common approach to calculate number e is to use a continued fraction based on the following sequence:
euler-sequence
Continued Fraction:
euler-continued-fraction

Complete your Python script to implement this continued fraction. (Method 3)

Extension Task:


This continued fraction for e converges three times as quickly:
euler-continued-fraction-2
This continued fraction for e converges three times as quickly.

Complete your Python script to implement this continued fraction. (Method 4)

Share Button
Posted in Computer Science, Python - Advanced, Python Challenges Tagged with: ,

Our Latest Book