Код: Выделить всё
list = {1, 2, 3, 4, 5}
Код: Выделить всё
input_set = {1, 2, 3, 4, 5}
fact = 1
for item in input_set:
for number in range(1,item+1):
fact = fact * number
print ("Factorial of", item, "is", fact)
Код: Выделить всё
Factorial of 1 is 1
Factorial of 2 is 2
Factorial of 3 is 12
Factorial of 4 is 288
Factorial of 5 is 34560
Мне бы очень хотелось знать, что не так с моим кодом и как это исправить.
Примечание. Я не хочу использовать функцию math.factorial для этого кода.
Подробнее здесь: https://stackoverflow.com/questions/465 ... of-numbers