Skip to content

Commit e0e2825

Browse files
committed
update
1 parent 2d49740 commit e0e2825

6 files changed

+3136
-6
lines changed

.ipynb_checkpoints/python_anonymous_functions-checkpoint.ipynb

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,9 +964,51 @@
964964
},
965965
{
966966
"cell_type": "code",
967-
"execution_count": null,
967+
"execution_count": 11,
968968
"id": "55f1a416",
969969
"metadata": {},
970+
"outputs": [
971+
{
972+
"name": "stdout",
973+
"output_type": "stream",
974+
"text": [
975+
"The factorial of 9 is 362880\n"
976+
]
977+
}
978+
],
979+
"source": [
980+
"# recursion\n",
981+
"\n",
982+
"def recur_factorial(n):\n",
983+
" if n == 1:\n",
984+
" return n\n",
985+
" else:\n",
986+
" return n*recur_factorial(n-1)\n",
987+
"\n",
988+
"num = 9\n",
989+
"\n",
990+
"# check if the number is negative\n",
991+
"if num < 0:\n",
992+
" print(\"Sorry, factorial does not exist for negative numbers\")\n",
993+
"elif num == 0:\n",
994+
" print(\"The factorial of 0 is 1\")\n",
995+
"else:\n",
996+
" print(\"The factorial of\", num, \"is\", recur_factorial(num))"
997+
]
998+
},
999+
{
1000+
"cell_type": "code",
1001+
"execution_count": null,
1002+
"id": "eb985ff7",
1003+
"metadata": {},
1004+
"outputs": [],
1005+
"source": []
1006+
},
1007+
{
1008+
"cell_type": "code",
1009+
"execution_count": null,
1010+
"id": "735f0f55",
1011+
"metadata": {},
9701012
"outputs": [],
9711013
"source": []
9721014
}

0 commit comments

Comments
 (0)