{"id":211,"date":"2025-05-29T13:13:01","date_gmt":"2025-05-29T07:43:01","guid":{"rendered":"https:\/\/codeanddebug.in\/blog\/?p=211"},"modified":"2025-07-07T19:57:31","modified_gmt":"2025-07-07T14:27:31","slug":"find-factorial-of-number-using-recursion","status":"publish","type":"post","link":"https:\/\/codeanddebug.in\/blog\/find-factorial-of-number-using-recursion\/","title":{"rendered":"Python Program to Find Factorial of Number Using Recursion"},"content":{"rendered":"\n<p>Hi everyone! In this article, we&#8217;ll guide you through the Python program to find factorial of number using recursion. The <strong>[<a href=\"https:\/\/www.geeksforgeeks.org\/problems\/factorial5739\/1\" target=\"_blank\" rel=\"noreferrer noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"><span style=\"text-decoration: underline;\">Problem Link<\/span><\/mark><\/a>]<\/strong> of which is attached here.<\/p>\n\n\n<div style=\"max-width: -moz-fit-content; \" class=\"wp-block-ub-table-of-contents-block ub_table-of-contents ub_table-of-contents-collapsed\" id=\"ub_table-of-contents-6c19285b-d954-4778-99ac-7a2272b9218a\" data-linktodivider=\"false\" data-showtext=\"show\" data-hidetext=\"hide\" data-scrolltype=\"auto\" data-enablesmoothscroll=\"true\" data-initiallyhideonmobile=\"false\" data-initiallyshow=\"false\"><div class=\"ub_table-of-contents-header-container\" style=\"\">\n\t\t\t<div class=\"ub_table-of-contents-header\" style=\"text-align: left; \">\n\t\t\t\t<div class=\"ub_table-of-contents-title\">Contents:<\/div>\n\t\t\t\t<div class=\"ub_table-of-contents-header-toggle\">\n\t\t\t<div class=\"ub_table-of-contents-toggle\" style=\"\">\n\t\t\t\u00a0[<a class=\"ub_table-of-contents-toggle-link\" href=\"#\" style=\"\">show<\/a>]\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/div><div class=\"ub_table-of-contents-extra-container\" style=\"\">\n\t\t\t<div class=\"ub_table-of-contents-container ub_table-of-contents-1-column ub-hide\">\n\t\t\t\t<ul style=\"\"><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/find-factorial-of-number-using-recursion\/#0-examples\" style=\"\">Examples<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/find-factorial-of-number-using-recursion\/#1-your-task\" style=\"\">Your Task<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/find-factorial-of-number-using-recursion\/#2-solution-of-the-python-program-to-find-factorial-of-number-using-recursion\" style=\"\">Solution of the Python Program to Find Factorial of Number Using Recursion<\/a><ul><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/find-factorial-of-number-using-recursion\/#3-problem-statement\" style=\"\">Problem Statement<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/find-factorial-of-number-using-recursion\/#4-intuition-and-approach\" style=\"\">Intuition and Approach<\/a><ul><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/find-factorial-of-number-using-recursion\/#5-why-recursion-works-here\" style=\"\">Why Recursion Works Here<\/a><\/li><\/ul><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/find-factorial-of-number-using-recursion\/#6-code\" style=\"\">Code<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/find-factorial-of-number-using-recursion\/#7-dry-run\" style=\"\">Dry Run<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/find-factorial-of-number-using-recursion\/#8-edge-cases\" style=\"\">Edge Cases<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/find-factorial-of-number-using-recursion\/#9-time-and-space-complexity\" style=\"\">Time and Space Complexity<\/a><\/li><\/ul><\/li><\/ul>\n\t\t\t<\/div>\n\t\t<\/div><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"0-examples\">Examples<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"Example 1:\n\n  Input: N = 5\n  Output:  120\n  Explanation: 5*4*3*2*1 = 120\n\nExample 2:\n\n  Input: N = 4\n  Output:   24\n  Explanation: 4*3*2*1 = 24\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">Example <\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Input: N = <\/span><span style=\"color: #B5CEA8\">5<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Output:  <\/span><span style=\"color: #B5CEA8\">120<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Explanation: <\/span><span style=\"color: #B5CEA8\">5<\/span><span style=\"color: #D4D4D4\">*<\/span><span style=\"color: #B5CEA8\">4<\/span><span style=\"color: #D4D4D4\">*<\/span><span style=\"color: #B5CEA8\">3<\/span><span style=\"color: #D4D4D4\">*<\/span><span style=\"color: #B5CEA8\">2<\/span><span style=\"color: #D4D4D4\">*<\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #B5CEA8\">120<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">Example <\/span><span style=\"color: #B5CEA8\">2<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Input: N = <\/span><span style=\"color: #B5CEA8\">4<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Output:   <\/span><span style=\"color: #B5CEA8\">24<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Explanation: <\/span><span style=\"color: #B5CEA8\">4<\/span><span style=\"color: #D4D4D4\">*<\/span><span style=\"color: #B5CEA8\">3<\/span><span style=\"color: #D4D4D4\">*<\/span><span style=\"color: #B5CEA8\">2<\/span><span style=\"color: #D4D4D4\">*<\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #B5CEA8\">24<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1-your-task\">Your Task<\/h2>\n\n\n\n<p>You don&#8217;t need to read input or print anything. Your task is to complete the function factorial() which takes an integer &#8220;N&#8221; as input parameters and returns an integer, the factorial of &#8220;N&#8221;.<\/p>\n\n\n\n<p><strong>Expected Time Complexity:<\/strong> O(N)<\/p>\n\n\n\n<p><strong>Expected Space Complexity:<\/strong> O(1)<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"Constraints: 0 &lt;= N &lt;= 18\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">Constraints: <\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\"> &lt;= N &lt;= <\/span><span style=\"color: #B5CEA8\">18<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2-solution-of-the-python-program-to-find-factorial-of-number-using-recursion\">Solution of the Python Program to Find Factorial of Number Using Recursion<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-problem-statement\">Problem Statement<\/h3>\n\n\n\n<p><strong>Given: <\/strong>A non-negative integer &#8220;N&#8221;.<\/p>\n\n\n\n<p><strong>Task: <\/strong>Compute the factorial of the given number &#8220;N&#8221;. The factorial of a number &#8220;N&#8221; is the product of all positive integers less than or equal to &#8220;N&#8221;. It is denoted by &#8220;N!&#8221; and is defined as:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>0! = 1<\/li>\n\n\n\n<li>1! = 1<\/li>\n\n\n\n<li>For N &gt; 1, N! = N \u00d7 (N-1) \u00d7 (N-2) \u00d7 &#8230; \u00d7 1<\/li>\n<\/ul>\n\n\n\n<p><strong>Constraints:<\/strong> 0 &lt;= N &lt;= 20 <em>(Assuming constraints based on typical factorial problems to prevent integer overflow in standard data types.)<\/em><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"Example 1:\n\n  Input: N = 5\n  Output: 120\n  Explanation: 5! = 5 \u00d7 4 \u00d7 3 \u00d7 2 \u00d7 1 = 120\n\nExample 2:\n\n  Input: N = 0\n  Output: 1\n  Explanation: By definition, 0! = 1\n\nExample 3:\n\n  Input: N = 3\n  Output: 6\n  Explanation: 3! = 3 \u00d7 2 \u00d7 1 = 6\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">Example <\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Input: N = <\/span><span style=\"color: #B5CEA8\">5<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Output: <\/span><span style=\"color: #B5CEA8\">120<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Explanation: <\/span><span style=\"color: #B5CEA8\">5<\/span><span style=\"color: #D4D4D4\">! = <\/span><span style=\"color: #B5CEA8\">5<\/span><span style=\"color: #D4D4D4\"> \u00d7 <\/span><span style=\"color: #B5CEA8\">4<\/span><span style=\"color: #D4D4D4\"> \u00d7 <\/span><span style=\"color: #B5CEA8\">3<\/span><span style=\"color: #D4D4D4\"> \u00d7 <\/span><span style=\"color: #B5CEA8\">2<\/span><span style=\"color: #D4D4D4\"> \u00d7 <\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #B5CEA8\">120<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">Example <\/span><span style=\"color: #B5CEA8\">2<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Input: N = <\/span><span style=\"color: #B5CEA8\">0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Output: <\/span><span style=\"color: #B5CEA8\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Explanation: By definition, <\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">! = <\/span><span style=\"color: #B5CEA8\">1<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">Example <\/span><span style=\"color: #B5CEA8\">3<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Input: N = <\/span><span style=\"color: #B5CEA8\">3<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Output: <\/span><span style=\"color: #B5CEA8\">6<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">  Explanation: <\/span><span style=\"color: #B5CEA8\">3<\/span><span style=\"color: #D4D4D4\">! = <\/span><span style=\"color: #B5CEA8\">3<\/span><span style=\"color: #D4D4D4\"> \u00d7 <\/span><span style=\"color: #B5CEA8\">2<\/span><span style=\"color: #D4D4D4\"> \u00d7 <\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #B5CEA8\">6<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>Also read about the Python Program to <strong><a href=\"https:\/\/codeanddebugacademy.com\/python-program-print-1-to-n-without-loops\/\" target=\"_blank\" rel=\"noreferrer noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"><span style=\"text-decoration: underline;\">Print from 1 to N Without Loops<\/span><\/mark><\/a><\/strong>.<\/em><\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4-intuition-and-approach\">Intuition and Approach<\/h3>\n\n\n\n<p><strong>Objective: <\/strong>To calculate the factorial of a given non-negative integer &#8220;N&#8221; efficiently.<\/p>\n\n\n\n<p><strong>Understanding Factorial:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Base Cases:<\/strong>\n<ul class=\"wp-block-list\">\n<li>0! = 1<\/li>\n\n\n\n<li>1! = 1<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Recursive Case:<\/strong> For N &gt; 1, N! = N \u00d7 (N-1)!<\/li>\n<\/ul>\n\n\n\n<p><strong>Approach Overview:<\/strong> The problem is a classic example of recursion, where the solution to a problem depends on solutions to smaller instances of the same problem.<\/p>\n\n\n\n<p>Here&#8217;s how recursion applies to calculating factorial:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Recursive Function (<\/strong><strong>func<\/strong><strong>):<\/strong>\n<ul class=\"wp-block-list\">\n<li>The function &#8220;func&#8221; is designed to compute the factorial of a given number &#8220;num&#8221;<\/li>\n\n\n\n<li>It checks for the base cases (num == 0 or num == 1) and returns 1 directly<\/li>\n\n\n\n<li>For other values, it calls itself with num &#8211; 1 and multiplies the result by &#8220;num&#8221;, effectively building up the factorial product.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Wrapper Function (<\/strong><strong>factorial<\/strong><strong>):<\/strong>\n<ul class=\"wp-block-list\">\n<li>The factorial function serves as an interface to the recursive &#8220;func&#8221;<\/li>\n\n\n\n<li>It takes the input number &#8220;N&#8221;, calls func(N), and returns the computed factorial<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"5-why-recursion-works-here\">Why Recursion Works Here<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Simplicity: <\/strong>Recursion provides a straightforward way to express the factorial calculation, aligning closely with its mathematical definition.<\/li>\n\n\n\n<li><strong>Breaking Down the Problem: <\/strong>By reducing the problem size (N to N-1), recursion handles each multiplication step systematically.<\/li>\n\n\n\n<li><strong>Handling Base Cases: <\/strong>Recursion inherently manages the stopping condition through base cases, ensuring termination.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"6-code\">Code<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"class Solution:\n    def func(self, num):\n        if num == 1 or num == 0:\n            return 1\n        return num * self.func(num - 1)\n\n    def factorial(self, N):\n        ans = self.func(N)\n        return ans\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">class<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">Solution<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">func<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">self<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #9CDCFE\">num<\/span><span style=\"color: #D4D4D4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> num == <\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">or<\/span><span style=\"color: #D4D4D4\"> num == <\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #B5CEA8\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> num * <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.func(num - <\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">factorial<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">self<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #9CDCFE\">N<\/span><span style=\"color: #D4D4D4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        ans = <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.func(N)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> ans<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided solution employs a recursive strategy to calculate the factorial of a given number. Here&#8217;s an integrated overview of how the code functions:<\/p>\n\n\n\n<p><strong>Recursive Function (func)<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"def func(self, num):\n    if num == 1 or num == 0:\n        return 1\n\n    return num * self.func(num - 1)\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">func<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">self<\/span><span style=\"color: #D4D4D4\">, <\/span><span style=\"color: #9CDCFE\">num<\/span><span style=\"color: #D4D4D4\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> num == <\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">or<\/span><span style=\"color: #D4D4D4\"> num == <\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #B5CEA8\">1<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> num * <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.func(num - <\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Purpose: <\/strong>The &#8220;func&#8221; method is responsible for computing the factorial of the input number &#8220;num&#8221; recursively.<\/li>\n\n\n\n<li><strong>Mechanism:<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Base Cases:<\/strong>\n<ul class=\"wp-block-list\">\n<li>If &#8220;num&#8221; is 0 or 1, the function returns 1 immediately, as per the definition of factorial.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Recursive Case:<\/strong>\n<ul class=\"wp-block-list\">\n<li>For num &gt; 1, the function calls itself with num &#8211; 1 and multiplies the result by &#8220;num.&#8221; This builds the factorial product step by step.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Example Flow:<\/strong> For func(3):\n<ul class=\"wp-block-list\">\n<li>func(3) calls func(2)<\/li>\n\n\n\n<li>func(2) calls func(1)<\/li>\n\n\n\n<li>func(1) returns 1<\/li>\n\n\n\n<li>func(2) returns 2 * 1 = 2<\/li>\n\n\n\n<li>func(3) returns 3 * 2 = 6<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>Explore about the Python Program to <strong><a href=\"https:\/\/codeanddebug.in\/blog\/python-program-print-divisors-factors-integer\/\" target=\"_blank\" rel=\"noreferrer noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"><span style=\"text-decoration: underline;\">Print Divisors\/Factors of an Integer<\/span><\/mark><\/a><\/strong>.<\/em><\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"7-dry-run\">Dry Run<\/h3>\n\n\n\n<p>To illustrate how the code operates, let&#8217;s walk through an example where N = 5.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Input:<\/strong> N = 5<\/li>\n\n\n\n<li><strong>Expected Output:<\/strong> 120 (since 5! = 5 \u00d7 4 \u00d7 3 \u00d7 2 \u00d7 1 = 120)<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdXmLFnvv02dcNDRDyXGwUJhghVAVwW8Pflw_HuG0w71bIeOPHrPTzdKoFbuCNCZgCEqQ0DwVprCDWWyRh6MwAxSLnoMfILKPvX4f3weBjX1n1Hz5uC-NxgnroDte8iSXfwhfxVgw?key=w4eRbLlKR-hM3MvFRYL-wA\" alt=\"Dry Run of the Python Program to Find Factorial of Number Using Recursion\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdKZb6Wsr6nMxn_ZYft596OZ5naxXAkQKhcfnPHdutWB69R8pSmDOp08dLijtplRdbahpwIU2LdyJ1_hiVAQNTWU0dQGZwmyGwYP8lKowTS4ZPAcuwGHRQs314UA0STXFH9K4OSLA?key=w4eRbLlKR-hM3MvFRYL-wA\" alt=\"Return Values of the Python Program to Find Factorial of Number Using Recursion\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"8-edge-cases\">Edge Cases<\/h3>\n\n\n\n<p>Ensuring that the solution handles all possible edge cases is crucial for its robustness. Here are some noteworthy scenarios:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Zero (<\/strong><strong>N = 0<\/strong><strong>):<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Input:<\/strong> N = 0<\/li>\n\n\n\n<li><strong>Expected Output:<\/strong> 1 (since 0! = 1)<\/li>\n\n\n\n<li><strong>Process:<\/strong>\n<ul class=\"wp-block-list\">\n<li>factorial(0) calls func(0)<\/li>\n\n\n\n<li>func(0) detects the base case and returns 1<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Result:<\/strong> 1<\/li>\n\n\n\n<li><strong>Explanation:<\/strong> By definition, the factorial of zero is one<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>One (<\/strong><strong>N = 1<\/strong><strong>):<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Input:<\/strong> N = 1<\/li>\n\n\n\n<li><strong>Expected Output:<\/strong> 1 (since 1! = 1)<\/li>\n\n\n\n<li><strong>Process:<\/strong>\n<ul class=\"wp-block-list\">\n<li>factorial(1) calls func(1)<\/li>\n\n\n\n<li>func(1) detects the base case and returns 1<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Result:<\/strong> 1<\/li>\n\n\n\n<li><strong>Explanation: <\/strong>The factorial of one is also one<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Single Digit Greater Than One (<\/strong><strong>N = 2<\/strong><strong>):<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Input:<\/strong> N = 2<\/li>\n\n\n\n<li><strong>Expected Output:<\/strong> 2 (since 2! = 2)<\/li>\n\n\n\n<li><strong>Process:<\/strong>\n<ul class=\"wp-block-list\">\n<li>factorial(2) calls func(2)<\/li>\n\n\n\n<li>func(2) computes 2 * func(1) = 2 * 1 = 2<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Result:<\/strong> 2<\/li>\n\n\n\n<li><strong>Explanation: <\/strong>Simple multiplication without carryover<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Multiple Digits with Carryover (<\/strong><strong>N = 5<\/strong><strong>):<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Input:<\/strong> N = 5<\/li>\n\n\n\n<li><strong>Expected Output:<\/strong> 120 (since 5! = 120)<\/li>\n\n\n\n<li><strong>Process:<\/strong>\n<ul class=\"wp-block-list\">\n<li>factorial(5) calls func(5)<\/li>\n\n\n\n<li>func(5) computes 5 * func(4) = 5 * 24 = 120<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Result:<\/strong> 120<\/li>\n\n\n\n<li><strong>Explanation: <\/strong>Demonstrates handling of multiple recursive calls and multiplication<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Large Number (<\/strong><strong>N = 20<\/strong><strong>):<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Input:<\/strong> N = 20<\/li>\n\n\n\n<li><strong>Expected Output:<\/strong> 2432902008176640000 (since 20! = 2432902008176640000)<\/li>\n\n\n\n<li><strong>Process:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The recursive calls handle each decrement from 20 down to 1, multiplying sequentially<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Result:<\/strong> 2432902008176640000<\/li>\n\n\n\n<li><strong>Explanation: <\/strong>Validates the function&#8217;s capability to handle larger inputs within the constraints<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Negative Number (<\/strong><strong>N = -1<\/strong><strong>):<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Input:<\/strong> N = -1<\/li>\n\n\n\n<li><strong>Expected Output:<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Behavior:<\/strong> The current implementation does not handle negative numbers<\/li>\n\n\n\n<li><strong>Result:<\/strong> Potentially infinite recursion or incorrect results<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Explanation: <\/strong>The function assumes &#8220;N&#8221; is a non-negative integer. Introducing negative numbers would lead to unintended behavior. To handle such cases, additional input validation should be incorporated.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>You might also like to read about the Python Program to <strong><a href=\"https:\/\/codeanddebug.in\/blog\/python-program-to-check-armstrong-number\/\" target=\"_blank\" rel=\"noreferrer noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"><span style=\"text-decoration: underline;\">Check Armstrong Number<\/span><\/mark><\/a><\/strong>.<\/em><\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"9-time-and-space-complexity\">Time and Space Complexity<\/h3>\n\n\n\n<p><strong>Time Complexity:<\/strong> O(N)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Explanation:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The &#8220;func&#8221; method makes a recursive call for each integer from &#8220;N&#8221; down to 0<\/li>\n\n\n\n<li>Therefore, the number of recursive calls grows linearly with &#8220;N&#8221;<\/li>\n\n\n\n<li>Each call performs a constant amount of work (a multiplication and a conditional check)<\/li>\n\n\n\n<li><strong>Overall:<\/strong> The time complexity scales linearly with the input size, <strong>O(N)<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>Space Complexity:<\/strong> O(N)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Explanation:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Due to recursion, each function call adds a new frame to the call stack<\/li>\n\n\n\n<li>For &#8220;N&#8221; recursive calls, the space used on the call stack grows linearly with &#8220;N&#8221;<\/li>\n\n\n\n<li><strong>Overall:<\/strong> The space complexity is linear, <strong>O(N)<\/strong>, primarily due to the recursion depth<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"has-white-color has-vivid-purple-background-color has-text-color has-background has-link-color wp-elements-9717cfbfb6a2807415d14311cddf85d3\"><em><strong>Note: <\/strong>While the time complexity is optimal for calculating factorials recursively, the space complexity can be a concern for very large values of &#8220;N&#8221; due to potential stack overflow. Iterative solutions can achieve O(1) space complexity but may sacrifice some of the elegance and simplicity of recursion.<\/em><\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"has-text-align-center\"><em>For any changes to the document, kindly email at <a href=\"mailto:code@codeanddebug.in\">code@codeanddebug.in<\/a> or contact us at <a href=\"tel:+91-9712928220\">+91-9712928220<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi everyone! In this article, we&#8217;ll guide you through the Python program to find factorial of number using recursion. The [Problem Link] of which is attached here. Examples Your Task You don&#8217;t need to read input or print anything. Your task is to complete the function factorial() which takes an integer &#8220;N&#8221; as input parameters<\/p>\n","protected":false},"author":1,"featured_media":214,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[8,11],"class_list":{"0":"post-211","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-data-structures-and-algorithm","8":"category-beginner","9":"tag-easy","10":"tag-recursion"},"featured_image_src":"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/05\/factorial-of-a-number-using-recursion-featured-image.png","author_info":{"display_name":"codeanddebug","author_link":"https:\/\/codeanddebug.in\/blog\/author\/codeanddebug\/"},"_links":{"self":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/comments?post=211"}],"version-history":[{"count":2,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":547,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/211\/revisions\/547"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media\/214"}],"wp:attachment":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media?parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/categories?post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/tags?post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}