Skip to content

Commit 201d755

Browse files
authored
Merge pull request #2 from nerdiumm/find_pi
Find pi + Find e
2 parents 90d9f9f + 40c1392 commit 201d755

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Hopefully, I and whoever else is looking into this repo will learn something new
88
optimize and capitalize on what I and whoever else have and will learn.
99

1010
## NUMBERS
11-
- [ ] **Find PI to the Nth Digit** - Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program will go.
11+
- [X] **Find PI to the Nth Digit** - Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program will go.
1212
- [ ] **Find e to the Nth Digit** - Just like the previous problem, but with e instead of PI. Enter a number and have the program generate e up to that many decimal places. Keep a limit to how far the program will go.
1313
- [ ] **Fibonacci Sequence** - Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number.
1414
- [ ] **Prime Factorization** - Have the user enter a number and find all Prime Factors (if there are any) and display them.

find_e.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# User enters a number. Generate e to the power of that number.
2+
# REMEMBER THE LIMITS OF HOW FAR THE PROGRAM CAN GO!
3+
#
4+
# Started: 14 January 2023
5+
# Completed: 14 January 2023
6+
7+
import math
8+
9+
user_inp = input("How many deciaml places would you like the math constant e? ")
10+
pwr = int(user_inp)
11+
12+
# I stopped at the 51st decimal point because after this, Python adds zeroes to
13+
# the end of the e.
14+
if pwr <= 51:
15+
str_format = "%." + user_inp + "f"
16+
print(str_format % math.e)
17+
else:
18+
print("I cannt go that far out into e.")

find_pi.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# User enter a number. Generate PI up to that many decimal places.
22
# REMEMBER THE LIMITS OF HOW FAR THE PROGRAM CAN GO!
3+
#
4+
# Started: 13 January 2023
5+
# Completed: 14 January 2023
36

47
import math
58

0 commit comments

Comments
 (0)