{"id":271,"date":"2025-06-09T14:10:06","date_gmt":"2025-06-09T08:40:06","guid":{"rendered":"https:\/\/codeanddebug.in\/blog\/?p=271"},"modified":"2025-06-09T14:11:18","modified_gmt":"2025-06-09T08:41:18","slug":"fibonacci-number","status":"publish","type":"post","link":"https:\/\/codeanddebug.in\/blog\/fibonacci-number\/","title":{"rendered":"Fibonacci Number | Recursive Python Solution"},"content":{"rendered":"\n<p>Find the <em>n-th<\/em> Fibonacci number with a recursive function in Python. Clear problem statement, examples, easy-to-grasp intuition, commented code, dry run, and Big-O complexity.<\/p>\n\n\n\n<p>The<strong> [<a href=\"https:\/\/leetcode.com\/problems\/fibonacci-number\/description\/\" 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> is given here for your quick reference.<\/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-c19ac9f6-4837-4e1b-898d-f272eeb854cd\" 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\/fibonacci-number\/#0-what-does-the-problem-ask\" style=\"\">What does the problem ask?<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/fibonacci-number\/#1-examples\" style=\"\">Examples<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/fibonacci-number\/#2-intuition-amp-approach\" style=\"\">Intuition &amp; Approach<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/fibonacci-number\/#3-code\" style=\"\">Code<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/fibonacci-number\/#4-code-explanation\" style=\"\">Code explanation<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/fibonacci-number\/#5-dry-run-for-n-5\" style=\"\">Dry run for n = 5<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/fibonacci-number\/#6-complexity\" style=\"\">Complexity<\/a><\/li><li style=\"\"><a href=\"https:\/\/codeanddebug.in\/blog\/fibonacci-number\/#7-conclusion\" style=\"\">Conclusion<\/a><\/li><\/ul>\n\t\t\t<\/div>\n\t\t<\/div><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"0-what-does-the-problem-ask\">What does the problem ask?<\/h2>\n\n\n\n<p>For a non-negative integer <code>n<\/code>, return the <em>n-th<\/em> value in the <strong>Fibonacci sequence<\/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=\"F(0) = 0\nF(1) = 1\nF(n) = F(n-1) + F(n-2)   for n \u2265 2\" 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\">F(<\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">) = <\/span><span style=\"color: #B5CEA8\">0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">F(<\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">) = <\/span><span style=\"color: #B5CEA8\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">F(n) = F(n-<\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">) + F(n-<\/span><span style=\"color: #B5CEA8\">2<\/span><span style=\"color: #D4D4D4\">)   <\/span><span style=\"color: #C586C0\">for<\/span><span style=\"color: #D4D4D4\"> n \u2265 <\/span><span style=\"color: #B5CEA8\">2<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1-examples\">Examples<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><code>n<\/code><\/th><th>Output<\/th><th>Sequence so far<\/th><\/tr><\/thead><tbody><tr><td>0<\/td><td>0<\/td><td>0<\/td><\/tr><tr><td>1<\/td><td>1<\/td><td>0 1<\/td><\/tr><tr><td>2<\/td><td>1<\/td><td>0 1 1<\/td><\/tr><tr><td>3<\/td><td>2<\/td><td>0 1 1 2<\/td><\/tr><tr><td>4<\/td><td>3<\/td><td>0 1 1 2 3<\/td><\/tr><tr><td>5<\/td><td>5<\/td><td>0 1 1 2 3 5<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>Also read about Leetcode #7 : <strong><a href=\"https:\/\/codeanddebug.in\/blog\/reverse-integer-python-program-explained\/\" 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;\">Reverse Integer Python Program<\/span><\/mark><\/a><\/strong>.<\/em><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2-intuition-amp-approach\">Intuition &amp; Approach<\/h2>\n\n\n\n<p>The definition of the Fibonacci sequence is <strong>self-referencing<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Base cases: <code>F(0) = 0<\/code>, <code>F(1) = 1<\/code>.<\/li>\n\n\n\n<li>Any larger <code>F(n)<\/code> equals the <strong>sum of the two previous numbers<\/strong>.<\/li>\n<\/ul>\n\n\n\n<p>This naturally maps to <strong>recursion<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If <code>n<\/code> is <code>0<\/code> or <code>1<\/code>, return it right away.<\/li>\n\n\n\n<li>Otherwise, call the same function for <code>n-1<\/code> and <code>n-2<\/code>, add the results, and return the sum.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-code\">Code<\/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=\"class Solution:\n    # helper that returns F(num)\n    def func(self, num):\n        if num &lt;= 1:            # base cases: F(0)=0, F(1)=1\n            return num\n        # recursive calls for previous two numbers\n        return self.func(num - 1) + self.func(num - 2)\n\n    def fib(self, n: int) -&gt; int:\n        # simply delegate to the helper\n        return self.func(n)\" 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: #6A9955\"># helper that returns F(num)<\/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 &lt;= <\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">:            <\/span><span style=\"color: #6A9955\"># base cases: F(0)=0, F(1)=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>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># recursive calls for previous two numbers<\/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: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.func(num - <\/span><span style=\"color: #B5CEA8\">1<\/span><span style=\"color: #D4D4D4\">) + <\/span><span style=\"color: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.func(num - <\/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\">    <\/span><span style=\"color: #569CD6\">def<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">fib<\/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 style=\"color: #4EC9B0\">int<\/span><span style=\"color: #D4D4D4\">) -&gt; <\/span><span style=\"color: #4EC9B0\">int<\/span><span style=\"color: #D4D4D4\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #6A9955\"># simply delegate to the helper<\/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: #569CD6\">self<\/span><span style=\"color: #D4D4D4\">.func(n)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4-code-explanation\">Code explanation<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong><code>func(num)<\/code><\/strong>\n<ul class=\"wp-block-list\">\n<li>If <code>num<\/code> is <code>0<\/code> or <code>1<\/code>, return it (ends recursion).<\/li>\n\n\n\n<li>Otherwise return <code>func(num-1) + func(num-2)<\/code>.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong><code>fib(n)<\/code><\/strong>\n<ul class=\"wp-block-list\">\n<li>Acts as a thin wrapper that calls <code>func<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>The recursion tree keeps expanding until every branch hits a base case, then sums bubble back up to the original call.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"5-dry-run-for-n-5\">Dry run for <code>n = 5<\/code><\/h2>\n\n\n\n<div class=\"wp-block-merpress-mermaidjs diagram-source-mermaid\"><pre class=\"mermaid\">graph TD\n    A[\"fib(5)&lt;br\/>calls func(5)\"] --> B[\"func(5)&lt;br\/>5 > 1, so recurse\"]\n    \n    B --> C[\"func(4)&lt;br\/>4 > 1, so recurse\"]\n    B --> D[\"func(3)&lt;br\/>3 > 1, so recurse\"]\n    \n    C --> E[\"func(3)&lt;br\/>3 > 1, so recurse\"]\n    C --> F[\"func(2)&lt;br\/>2 > 1, so recurse\"]\n    \n    D --> G[\"func(2)&lt;br\/>2 > 1, so recurse\"]\n    D --> H[\"func(1)&lt;br\/>1 \u2264 1, return 1\"]\n    \n    E --> I[\"func(2)&lt;br\/>2 > 1, so recurse\"]\n    E --> J[\"func(1)&lt;br\/>1 \u2264 1, return 1\"]\n    \n    F --> K[\"func(1)&lt;br\/>1 \u2264 1, return 1\"]\n    F --> L[\"func(0)&lt;br\/>0 \u2264 1, return 0\"]\n    \n    G --> M[\"func(1)&lt;br\/>1 \u2264 1, return 1\"]\n    G --> N[\"func(0)&lt;br\/>0 \u2264 1, return 0\"]\n    \n    I --> O[\"func(1)&lt;br\/>1 \u2264 1, return 1\"]\n    I --> P[\"func(0)&lt;br\/>0 \u2264 1, return 0\"]\n    \n    %% Return value annotations\n    H -.-> |\"returns 1\"| D\n    J -.-> |\"returns 1\"| E\n    K -.-> |\"returns 1\"| F\n    L -.-> |\"returns 0\"| F\n    M -.-> |\"returns 1\"| G\n    N -.-> |\"returns 0\"| G\n    O -.-> |\"returns 1\"| I\n    P -.-> |\"returns 0\"| I\n    \n    %% Intermediate calculations\n    I -.-> |\"1 + 0 = 1\"| E\n    E -.-> |\"1 + 1 = 2\"| C\n    F -.-> |\"1 + 0 = 1\"| C\n    C -.-> |\"2 + 1 = 3\"| B\n    \n    G -.-> |\"1 + 0 = 1\"| D\n    D -.-> |\"1 + 1 = 2\"| B\n    \n    B -.-> |\"3 + 2 = 5\"| A\n    \n    %% Styling\n    classDef baseCase fill:#e1f5fe,stroke:#01579b,stroke-width:2px\n    classDef recursive fill:#fff3e0,stroke:#e65100,stroke-width:2px\n    classDef result fill:#e8f5e8,stroke:#2e7d32,stroke-width:2px\n    \n    class H,J,K,L,M,N,O,P baseCase\n    class B,C,D,E,F,G,I recursive\n    class A result<\/pre><\/div>\n\n\n\n<p>So <code>fib(5)<\/code> returns 5.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6-complexity\">Complexity<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Measure<\/th><th>Value<\/th><\/tr><\/thead><tbody><tr><td><strong>Time<\/strong><\/td><td><strong>O(2\u207f)<\/strong> \u2013 every call branches into two more calls until base cases.<\/td><\/tr><tr><td><strong>Space<\/strong><\/td><td><strong>O(n)<\/strong> \u2013 maximum depth of the recursion stack.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><em>In plain words:<\/em> the recursive method is easy to write but repeats work many times, making it slow for large <code>n<\/code>. The memory used grows linearly with <code>n<\/code> because each pending call waits on its two children.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"7-conclusion\">Conclusion<\/h2>\n\n\n\n<p>A direct recursive implementation follows the mathematical definition of Fibonacci numbers and is great for learning recursion. For bigger inputs you would switch to memoization or an iterative approach, but this simple version clearly shows the concept in just a few lines of Python.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-16018d1d wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/codeanddebug.in\/course\/master-dsa-with-leetcode\" target=\"_blank\" rel=\"noreferrer noopener\">Join our FREE Advance DSA COURSE<\/a><\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><em>For any changes to the article, 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\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Find the n-th Fibonacci number with a recursive function in Python. Clear problem statement, examples, easy-to-grasp intuition, commented code, dry run, and Big-O complexity. The [Problem Link] is given here for your quick reference. What does the problem ask? For a non-negative integer n, return the n-th value in the Fibonacci sequence: Examples n Output<\/p>\n","protected":false},"author":1,"featured_media":273,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[8,10,11],"class_list":{"0":"post-271","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-math","11":"tag-recursion"},"featured_image_src":"https:\/\/codeanddebug.in\/blog\/wp-content\/uploads\/2025\/06\/fibonacci-number-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\/271","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=271"}],"version-history":[{"count":3,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/271\/revisions"}],"predecessor-version":[{"id":275,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/posts\/271\/revisions\/275"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media\/273"}],"wp:attachment":[{"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/media?parent=271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/categories?post=271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeanddebug.in\/blog\/wp-json\/wp\/v2\/tags?post=271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}