1 X 2 X 3 X ... X 2018
My computer solves for the above product and finds its digit sum (sum of all its digits). It then repeats this process of calculating the digit sum until only one digit remains.
What digit is that?
import math | |
number = math.factorial(2018) | |
number_str = str(number) | |
while (len(number_str) != 1): | |
number = sum([int(i) for i in number_str]) | |
number_str = str(number) | |
print("Digit %s: " % number_str) |