mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-19 19:03:02 +08:00
[Project Euler] Fix code style for problems 15 and 34 (#3076)
* Add type hints and default args to problem 15 * Changes function's name to solution in problem 34 * Update sol1.py * Update sol1.py Co-authored-by: Dhruv <dhruvmanila@gmail.com>
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
"""
|
||||
Problem 34: https://projecteuler.net/problem=34
|
||||
|
||||
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
|
||||
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
|
||||
Note: As 1! = 1 and 2! = 2 are not sums they are not included.
|
||||
@ -18,12 +20,12 @@ def sum_of_digit_factorial(n: int) -> int:
|
||||
return sum(factorial(int(char)) for char in str(n))
|
||||
|
||||
|
||||
def compute() -> int:
|
||||
def solution() -> int:
|
||||
"""
|
||||
Returns the sum of all numbers whose
|
||||
sum of the factorials of all digits
|
||||
add up to the number itself.
|
||||
>>> compute()
|
||||
>>> solution()
|
||||
40730
|
||||
"""
|
||||
limit = 7 * factorial(9) + 1
|
||||
@ -31,4 +33,4 @@ def compute() -> int:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f"{compute()} = ")
|
||||
print(f"{solution()} = ")
|
||||
|
Reference in New Issue
Block a user