Skip to content

Hacktoberfest 2020 - coding style for project_euler problem 63 #3026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions project_euler/problem_63/sol1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number,
134217728=89, is a ninth power.
https://projecteuler.net/problem=63

The 5-digit number, 16807=7**5, is also a fifth power. Similarly, the 9-digit number,
134217728=8**9, is a ninth power.
How many n-digit positive integers exist which are also an nth power?
"""

Expand All @@ -11,7 +13,7 @@
"""


def compute_nums(max_base: int = 10, max_power: int = 22) -> int:
def compute_nums(max_base: int, max_power: int) -> int:
"""
Returns the count of all n-digit numbers which are nth power
>>> compute_nums(10, 22)
Expand All @@ -30,5 +32,10 @@ def compute_nums(max_base: int = 10, max_power: int = 22) -> int:
)


def solution(max_base: int = 10, max_power: int = 22) -> int:
"""Returns the count of all n-digit numbers which are nth power."""
return compute_nums(max_base, max_power)


if __name__ == "__main__":
print(f"{compute_nums(10, 22) = }")
print(f"{solution(10, 22) = }")