diff --git a/Seth_A99501/day12.ipynb b/Seth_A99501/day12.ipynb new file mode 100644 index 00000000..a8f69575 --- /dev/null +++ b/Seth_A99501/day12.ipynb @@ -0,0 +1,54 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The factorial of 5 is 120\n" + ] + } + ], + "source": [ + "def factorial(x):\n", + " #a recursive function to find the factorial of an integer\n", + "\n", + " if x == 1:\n", + " return 1\n", + " elif x<=0:\n", + " print(\"No factorial\")\n", + " else:\n", + " return (x * factorial(x-1))\n", + "\n", + "\n", + "num = int(input('Enter a number:'))\n", + "print(\"The factorial of\", num, \"is\", factorial(num))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.6" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}