diff --git a/maths/factorial.py b/maths/factorial.py index ba61447c7564..9082ad241dc3 100644 --- a/maths/factorial.py +++ b/maths/factorial.py @@ -5,25 +5,13 @@ def factorial(number: int) -> int: """ - Calculate the factorial of specified number (n!). - >>> import math - >>> all(factorial(i) == math.factorial(i) for i in range(20)) - True - >>> factorial(0.1) - Traceback (most recent call last): - ... - ValueError: factorial() only accepts integral values - >>> factorial(-1) - Traceback (most recent call last): - ... - ValueError: factorial() not defined for negative values - >>> factorial(1) - 1 - >>> factorial(6) - 720 - >>> factorial(0) - 1 + Calculate the factorial of a non-negative integer. + + :param n: non-negative integer + :return: factorial of n + :raises ValueError: if n is negative + """ if number != int(number): raise ValueError("factorial() only accepts integral values") diff --git a/strings/palindrome.py b/strings/palindrome.py index e765207e5942..f4e88c516733 100644 --- a/strings/palindrome.py +++ b/strings/palindrome.py @@ -20,10 +20,10 @@ def is_palindrome(s: str) -> bool: """ - Return True if s is a palindrome otherwise return False. + Check whether a given string is a palindrome. - >>> all(is_palindrome(key) is value for key, value in test_data.items()) - True + :param s: input string + :return: True if palindrome, False otherwise """ start_i = 0