[ENHANCEMENT] Use and instead of bitwise and

and is faster
This commit is contained in:
defterade
2019-09-22 21:32:51 +02:00
committed by GitHub
parent 29daf0479d
commit 2ab5c2049c

View File

@ -12,7 +12,7 @@ Throws an exception if `num` is a negative or a floating point number.
```py ```py
def factorial(num): def factorial(num):
if not ((num >= 0) & (num % 1 == 0)): if not ((num >= 0) and (num % 1 == 0)):
raise Exception( raise Exception(
f"Number( {num} ) can't be floating point or negative ") f"Number( {num} ) can't be floating point or negative ")
return 1 if num == 0 else num * factorial(num - 1) return 1 if num == 0 else num * factorial(num - 1)