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 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,