diff options
| author | Paulo Custodio <pauloscustodio@gmail.com> | 2021-11-24 19:46:21 +0000 |
|---|---|---|
| committer | Paulo Custodio <pauloscustodio@gmail.com> | 2021-11-24 19:46:21 +0000 |
| commit | c4b1cc1f94522a4ea4958ef9f10af9b6bebce78a (patch) | |
| tree | 8956b9ed7c0a3c7826cb42509de2acc2070d25bb /challenge-021/paulo-custodio/python/ch-1.py | |
| parent | 05ec7ce53c5bb5bb898c992d782ddc322099cdf7 (diff) | |
| download | perlweeklychallenge-club-c4b1cc1f94522a4ea4958ef9f10af9b6bebce78a.tar.gz perlweeklychallenge-club-c4b1cc1f94522a4ea4958ef9f10af9b6bebce78a.tar.bz2 perlweeklychallenge-club-c4b1cc1f94522a4ea4958ef9f10af9b6bebce78a.zip | |
Add Python solution to challenge 21
Diffstat (limited to 'challenge-021/paulo-custodio/python/ch-1.py')
| -rw-r--r-- | challenge-021/paulo-custodio/python/ch-1.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-021/paulo-custodio/python/ch-1.py b/challenge-021/paulo-custodio/python/ch-1.py new file mode 100644 index 0000000000..134b371ad3 --- /dev/null +++ b/challenge-021/paulo-custodio/python/ch-1.py @@ -0,0 +1,22 @@ +#!/usr/bin/python3 + +# Challenge 021 +# +# Task #1 +# Write a script to calculate the value of e, also known as Euler's number and +# Napier's constant. Please checkout wiki page for more information. + +def calc_e(): + e = 1 + n = 0 + prod = 1 + prev = 0 + while prev != e: + prev = e + n += 1 + prod *= n + e += 1/prod + + return e + +print("{:.14f}".format(calc_e())) |
