Travis build: 110

This commit is contained in:
30secondsofcode
2019-09-23 02:08:27 +00:00
parent 74a0580cea
commit 06c866e0af
3 changed files with 4 additions and 4 deletions

View File

@ -1233,7 +1233,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)

View File

@ -368,7 +368,7 @@
] ]
}, },
"meta": { "meta": {
"hash": "3241103df06912913bbcfb51e03c1d355a7329e367aa9d4f6a770683bc196df8" "hash": "948d8f496825413a0047464055ab9166016ad526d26d83f3ceacd3dc5a1926ba"
} }
}, },
{ {

View File

@ -478,7 +478,7 @@
"fileName": "factorial.md", "fileName": "factorial.md",
"text": "Calculates the factorial of a number.\n\nUse recursion. \nIf `num` is less than or equal to `1`, return `1`. \nOtherwise, return the product of `num` and the factorial of `num - 1`. \nThrows an exception if `num` is a negative or a floating point number.\n\n", "text": "Calculates the factorial of a number.\n\nUse recursion. \nIf `num` is less than or equal to `1`, return `1`. \nOtherwise, return the product of `num` and the factorial of `num - 1`. \nThrows an exception if `num` is a negative or a floating point number.\n\n",
"codeBlocks": { "codeBlocks": {
"code": "def factorial(num):\n if not ((num >= 0) & (num % 1 == 0)):\n raise Exception(\n f\"Number( {num} ) can't be floating point or negative \")\n return 1 if num == 0 else num * factorial(num - 1)", "code": "def factorial(num):\n if not ((num >= 0) and (num % 1 == 0)):\n raise Exception(\n f\"Number( {num} ) can't be floating point or negative \")\n return 1 if num == 0 else num * factorial(num - 1)",
"example": "factorial(6) # 720" "example": "factorial(6) # 720"
}, },
"tags": [ "tags": [
@ -488,7 +488,7 @@
] ]
}, },
"meta": { "meta": {
"hash": "3241103df06912913bbcfb51e03c1d355a7329e367aa9d4f6a770683bc196df8" "hash": "948d8f496825413a0047464055ab9166016ad526d26d83f3ceacd3dc5a1926ba"
} }
}, },
{ {