Make Lesson 2 Task 4 not use math library

This commit is contained in:
Stanislav Mykhailenko 2022-11-03 19:33:19 +02:00
parent b65ed5adbe
commit ea949f4325
GPG key ID: 1E95E66A9C9D6A36

View file

@ -6,7 +6,7 @@
# 0 - OK
# 1 - Invalid number entered
import math, sys
import sys
def numberError():
print("Invalid number entered.")
@ -17,4 +17,9 @@ except ValueError: numberError()
if number < 1: numberError()
print(str(number) + " factorial is " + str(math.factorial(number)))
factorial = 1
for i in range(2, number + 1):
factorial = factorial * i
else:
print(str(number) + " factorial is " + str(factorial))