Beta
Digits of e
5 of 7Dr Gabo
Description:
About Euler's Number
Euler's Number (commonly called e), is a famous irrational constant that arises in lots of different contexts related to mathematics and engineering. It can be expressed as:
Source: Wikipedia
But there are multiple ways of approximating e, being ones more efficient than others. Some methods might become unfeasible over a certain precision level.
Your task
Write a function int calc_e(unsigned int n)
that takes a number n
and returns the n
-th digit of e.
Technical notes:
- There is a limit of 700 bytes (not characters) to prevent hardcoding.
- Only values of
n
in the range [0, 10000] (both included) will be tested.- 50 first digits.
- 200 random tests in the range [0, 1000].
- 200 random tests in the range [1000, 5000].
- 200 random tests in the range [5000, 10000].
- Mind the performance!
- This kata performs an anti-cheat analysis, so your code might be flagged as wrong if you use suspicious snippets (such as preprocessor or other programming languages). You should avoid interacting with the system (opening files, executing commands, etc).
Examples
// e ≈ 2.718281828459045...
e_digit(0) == 2
e_digit(1) == 7
e_digit(2) == 1
e_digit(3) == 8
e_digit(4) == 2
Mathematics
Performance
Algorithms
Similar Kata:
Stats:
Created | Apr 17, 2020 |
Published | Apr 17, 2020 |
Warriors Trained | 132 |
Total Skips | 31 |
Total Code Submissions | 93 |
Total Times Completed | 7 |
C++ Completions | 5 |
Total Stars | 2 |
% of votes with a positive feedback rating | 100% of 2 |
Total "Very Satisfied" Votes | 2 |
Total "Somewhat Satisfied" Votes | 0 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 3 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |