Pure Programmer
Blue Matrix


Cluster Map

Project: Calculate Euler's Number

You can calculate the value of [[E_(mathematical_constant)|Euler's Number]] (𝑒) using an infinite series that uses the factorial function.

`e = sum_(n=0)^oo 1/(n!)`

or

`e = 1 + 1/(1!) + 1/(2!) + 1/(3!) + 1/(4!) + 1/(5!) + ...`

where the factorial n! is:

`n! = 1*2*3*4*5*...*n`

Write a function to compute Euler's Number to a specified number of terms N that is passed to the function. Test the function with various values of N.

Output
$ swiftc CalculateEulersNumber.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation)

Solution