n! means n × (n − 1) × … × 3 × 2 × 1
For example, 10! = 10 × 9 × … × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
cevap : 648
Derleme ortami python
# project euler problem 20
# yasin tasan --> jan 2017
remainder = 0
number = 100
sum = 0
result = 0
product = 1
for i in range(1, number+1, 1):
product = i * product
print("i = ",i,"iken product =",product)
result = product
print(number, "e gore result =",result)
print("############################")
while result != 0:
remainder = result % 10
print("remainder = result % 10 -> remainder =",remainder)
sum = sum + remainder
print("sum = sum + remainder -> sum =",sum)
result = result//10 # virgulden sonraki sag tarafi ciddiye alma
print("result = int(result / 10) -> result =",result)
print("")
print("result toplami =",sum)