From 0a640c6f53ace36f09f8dd51ce35d7f2ca85f255 Mon Sep 17 00:00:00 2001 From: Nur Afdlol M <65208494+snorlaxzeroone@users.noreply.github.com> Date: Sat, 9 Oct 2021 21:11:09 +0700 Subject: [PATCH] create factorialrecursive.py --- Data Structures/Recursion/factorialrecursive.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Data Structures/Recursion/factorialrecursive.py diff --git a/Data Structures/Recursion/factorialrecursive.py b/Data Structures/Recursion/factorialrecursive.py new file mode 100644 index 00000000..30b251c6 --- /dev/null +++ b/Data Structures/Recursion/factorialrecursive.py @@ -0,0 +1,12 @@ +# Python 3 program to find +# factorial of given number +def factorial(n): + + # single line to find factorial + return 1 if (n==1 or n==0) else n * factorial(n - 1); + +# Driver Code +num = 5; +print("Factorial of",num,"is", +factorial(num)) +# Code contributed by Afdlol