diff --git a/kyu_7/factorial/factorial.py b/kyu_7/factorial/factorial.py index ab932991f50..0e36e94d631 100644 --- a/kyu_7/factorial/factorial.py +++ b/kyu_7/factorial/factorial.py @@ -1,6 +1,8 @@ -# Created by Egor Kostan. -# GitHub: https://github.com/ikostan -# LinkedIn: https://www.linkedin.com/in/egor-kostan/ +""" +Solution for -> Sum of Numbers +Created by Egor Kostan. +GitHub: https://github.com/ikostan +""" def factorial(n: int) -> int: @@ -11,12 +13,12 @@ def factorial(n: int) -> int: :param n: :return: """ - if n < 0 or n > 12: raise ValueError('Invalid input: {}'.format(n)) - result = 1 + result: int = 1 while n > 0: result *= n n -= 1 + return result diff --git a/kyu_7/factorial/test_factorial.py b/kyu_7/factorial/test_factorial.py index 3d3f13e9302..77b43204b0b 100644 --- a/kyu_7/factorial/test_factorial.py +++ b/kyu_7/factorial/test_factorial.py @@ -1,6 +1,8 @@ -# Created by Egor Kostan. -# GitHub: https://github.com/ikostan -# LinkedIn: https://www.linkedin.com/in/egor-kostan/ +""" +Test for -> Sum of Numbers +Created by Egor Kostan. +GitHub: https://github.com/ikostan +""" # FUNDAMENTALS ALGORITHMS NUMBERS @@ -38,24 +40,25 @@ def test_factorial(self): ValueError (Python). :return: """ - + # pylint: disable-msg=R0801 allure.dynamic.title("Testing 'factorial' function") allure.dynamic.severity(allure.severity_level.NORMAL) - allure.dynamic.description_html('

Codewars badge:

' - '' - '

Test Description:

' - "

") - + allure.dynamic.description_html( + '

Codewars badge:

' + '' + '

Test Description:

' + "

") + # pylint: enable-msg=R0801 with allure.step("Enter a number and verify the output"): - data = [ + data: tuple = ( (0, 1, "factorial for 0 is 1"), (1, 1, "factorial for 1 is 1"), (2, 2, "factorial for 2 is 2"), - (3, 6, "factorial for 3 is 6"), - ] + (3, 6, "factorial for 3 is 6")) for n, expected, msg in data: + print_log(n=n, expected=expected, msg=msg)