From 1f88fffd1441e1c3b3818b1931ac3c67c4e41091 Mon Sep 17 00:00:00 2001 From: VenkataRamana13 Date: Sat, 10 Jun 2023 00:50:10 +0530 Subject: [PATCH 1/2] Slight modification to day - 1 question 2 --- notebooks/Day_01.ipynb | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/notebooks/Day_01.ipynb b/notebooks/Day_01.ipynb index 66a65ba..24b87aa 100644 --- a/notebooks/Day_01.ipynb +++ b/notebooks/Day_01.ipynb @@ -128,7 +128,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "- **Using Lambda Function**" + "- **Using Recursion**" ] }, { @@ -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": {}, @@ -227,7 +245,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -241,7 +259,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.6" + "version": "3.9.12" } }, "nbformat": 4, From a8cf165dadcb9a3302a5901635b1d7284b8c4f89 Mon Sep 17 00:00:00 2001 From: VenkataRamana13 Date: Sat, 10 Jun 2023 00:51:20 +0530 Subject: [PATCH 2/2] Slight modification to day 1 question 2 --- Status/Day 1.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Status/Day 1.md b/Status/Day 1.md index 557714e..cbab239 100644 --- a/Status/Day 1.md +++ b/Status/Day 1.md @@ -93,7 +93,7 @@ print fact(x) fact = fact * i print(fact) ``` -- **Using Lambda Function** +- **Using recursion** ```python # Solution by: harshraj22 @@ -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