Skip to content
Merged
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
4 changes: 3 additions & 1 deletion project_euler/problem_034/sol1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from math import factorial

DIGIT_FACTORIAL = {str(d): factorial(d) for d in range(10)}


def sum_of_digit_factorial(n: int) -> int:
"""
Expand All @@ -17,7 +19,7 @@ def sum_of_digit_factorial(n: int) -> int:
>>> sum_of_digit_factorial(0)
1
"""
return sum(factorial(int(char)) for char in str(n))
return sum(DIGIT_FACTORIAL[d] for d in str(n))


def solution() -> int:
Expand Down