diff --git a/Lesson_2/task4.py b/Lesson_2/task4.py index ac53bfe..e7cc733 100644 --- a/Lesson_2/task4.py +++ b/Lesson_2/task4.py @@ -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))