Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Status/Day 1.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ print fact(x)
fact = fact * i
print(fact)
```
- **Using Lambda Function**
- **Using recursion**

```python
# Solution by: harshraj22
Expand All @@ -102,6 +102,12 @@ print fact(x)
def shortFact(x): return 1 if x <= 1 else x*shortFact(x-1)
print(shortFact(n))

```
- **Using lambda function**
```python
n = int(input())
fact = lambda n : 1 if n <= 1 else n * fact(n - 1)
print(fact(n))
```
---
```python
Expand Down
24 changes: 21 additions & 3 deletions notebooks/Day_01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"- **Using Lambda Function**"
"- **Using Recursion**"
]
},
{
Expand All @@ -148,6 +148,24 @@
"print(shortFact(n))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- **Using lambda function**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"n = int(input())\n",
"fact = lambda n : 1 if n <= 1 else n * fact(n - 1)\n",
"print(fact(n))"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -227,7 +245,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -241,7 +259,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down