{"id":12159,"date":"2022-09-27T11:50:00","date_gmt":"2022-09-27T06:20:00","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/"},"modified":"2025-09-26T10:32:52","modified_gmt":"2025-09-26T05:02:52","slug":"fibonacci-series-in-python","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/","title":{"rendered":"Complete Guide to Fibonacci in Python"},"content":{"rendered":"\n<p>The Fibonacci sequence appears in interviews to evaluate your coding skills, problem-solving skills, and knowledge of performance optimization. It is used by Google, Microsoft, and other companies to determine the efficiency with which you code.<\/p>\n\n\n\n<p>Outside of interviews, Fibonacci appears in nature, for example, in flower petals and pinecone spirals. It is also used in analyzing the stock market.<\/p>\n\n\n\n<p>Don't worry if you don't get the difficult mathematics. This tutorial will stick to useful <a href=\"https:\/\/www.mygreatlearning.com\/blog\/python-tutorial-for-beginners-a-complete-guide\/\">Python coding<\/a> methods that you can implement immediately.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-the-fibonacci-sequence\">What is the Fibonacci Sequence?<\/h2>\n\n\n\n<p>The Fibonacci sequence is a series where each number equals the sum of the two numbers before it:<\/p>\n\n\n\n<p>0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55...<\/p>\n\n\n<figure class=\"wp-block-image aligncenter size-full zoomable\" data-full=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/fibonacci-series-1756379835270.webp\"><img decoding=\"async\" width=\"800\" height=\"300\" src=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/fibonacci-series-1756379835270.webp\" alt=\"Fibonacci Sequence\" class=\"wp-image-111397\" srcset=\"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/fibonacci-series-1756379835270.webp 800w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/fibonacci-series-1756379835270-300x113.webp 300w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/fibonacci-series-1756379835270-768x288.webp 768w, https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/fibonacci-series-1756379835270-150x56.webp 150w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>Here's how it works:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Start with 0 and 1<\/li>\n\n\n\n<li>Add them: 0 + 1 = 1<\/li>\n\n\n\n<li>Add the last two: 1 + 1 = 2<\/li>\n\n\n\n<li>Keep going: 1 + 2 = 3, then 2 + 3 = 5, and so on<\/li>\n<\/ul>\n\n\n\n<p>The math formula is: F(n) = F(n-1) + F(n-2)<\/p>\n\n\n\n    <div class=\"courses-cta-container\">\n        <div class=\"courses-cta-card\">\n            <div class=\"courses-cta-header\">\n                <div class=\"courses-learn-icon\"><\/div>\n                <span class=\"courses-learn-text\">Free Course<\/span>\n            <\/div>\n            <p class=\"courses-cta-title\">\n                <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/python-fundamentals-for-beginners\" class=\"courses-cta-title-link\">Python Fundamentals for Beginners Free Course<\/a>\n            <\/p>\n            <p class=\"courses-cta-description\">Master Python basics, from variables to data structures and control flow. Solve real-time problems and build practical skills using Jupyter Notebook.<\/p>\n            <div class=\"courses-cta-stats\">\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-user-icon\"><\/div>\n                    <span>13.5 hrs<\/span>\n                <\/div>\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-star-icon\"><\/div>\n                    <span>4.55<\/span>\n                <\/div>\n            <\/div>\n            <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/python-fundamentals-for-beginners\" class=\"courses-cta-button\">\n                Enroll for Free\n                <div class=\"courses-arrow-icon\"><\/div>\n            <\/a>\n        <\/div>\n    <\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"method-1-simple-loop-best-choice\">Method 1: Simple Loop (Best Choice)<\/h2>\n\n\n\n<p>This is usually what you want to use:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npython\ndef fibonacci(n):\n    if n &amp;lt;= 1:\n        return n\n    \n    # Start with first two numbers\n    prev, curr = 0, 1\n    \n    # Calculate each number once\n    for i in range(2, n + 1):\n        prev, curr = curr, prev + curr\n    \n    return curr\n\n# Test it\nprint(fibonacci(10))  # Output: 55\nprint(fibonacci(0))   # Output: 0\nprint(fibonacci(1))   # Output: 1\n\n<\/pre><\/div>\n\n\n<p>Why this is good:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Fast: calculates each number only once<\/li>\n\n\n\n<li>Uses very little memory<\/li>\n\n\n\n<li>Easy to understand once you trace through it<\/li>\n\n\n\n<li>Works for large numbers<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"method-2-recursion-looks-nice-but-slow\">Method 2: Recursion (Looks Nice, But Slow)<\/h2>\n\n\n\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Recursion_(computer_science)\" target=\"_blank\" rel=\"noreferrer noopener\">Recursion<\/a>\u00a0is when a function calls itself. The recursive solution matches the Fibonacci mathematical formula.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npython\ndef fibonacci_recursive(n):\n    if n &amp;lt;= 1:\n        return n\n    return fibonacci_recursive(n-1) + fibonacci_recursive(n-2)\n\nprint(fibonacci_recursive(10))  # Output: 55\n\n<\/pre><\/div>\n\n\n<p>The problem: This is extremely slow for big numbers because it recalculates the same values over and over. Try fibonacci_recursive(40) and watch it take forever.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"method-3-smart-recursion-with-memory\">Method 3: Smart Recursion with Memory<\/h2>\n\n\n\n<p>If you want recursion that's actually fast, use memoization:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npython\ndef fibonacci_memo(n, memo={}):\n    if n in memo:\n        return memo&#x5B;n]\n    \n    if n &amp;lt;= 1:\n        return n\n    \n    result = fibonacci_memo(n-1, memo) + fibonacci_memo(n-2, memo)\n    memo&#x5B;n] = result\n    return result\n\nprint(fibonacci_memo(50))  # Fast now!\n\n<\/pre><\/div>\n\n\n<p>Or use Python's built-in cache:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npython\nfrom functools import lru_cache\n\n@lru_cache(maxsize=None)\ndef fibonacci_cached(n):\n    if n &amp;lt;= 1:\n        return n\n    return fibonacci_cached(n-1) + fibonacci_cached(n-2)\n\nprint(fibonacci_cached(100))  # Very fast\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"getting-multiple-fibonacci-numbers\">Getting Multiple Fibonacci Numbers<\/h2>\n\n\n\n<p>Want the first N Fibonacci numbers as a list?<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npython\ndef fibonacci_sequence(n):\n    if n &amp;lt;= 0:\n        return &#x5B;]\n    if n == 1:\n        return &#x5B;0]\n    \n    sequence = &#x5B;0, 1]\n    for i in range(2, n):\n        next_num = sequence&#x5B;i-1] + sequence&#x5B;i-2]\n        sequence.append(next_num)\n    \n    return sequence\n\nprint(fibonacci_sequence(10))\n# Output: &#x5B;0, 1, 1, 2, 3, 5, 8, 13, 21, 34]\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"performance-comparison\">Performance Comparison<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Method<\/th><th>Speed<\/th><th>Memory<\/th><th>Good for<\/th><\/tr><\/thead><tbody><tr><td>Simple loop<\/td><td>Very fast<\/td><td>Very low<\/td><td>Almost everything<\/td><\/tr><tr><td>Basic recursion<\/td><td>Extremely slow<\/td><td>High<\/td><td>Small numbers only (n &lt; 30)<\/td><\/tr><tr><td>Cached recursion<\/td><td>Fast<\/td><td>Medium<\/td><td>When you need recursion<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"common-mistakes\">Common Mistakes<\/h2>\n\n\n\n<p><strong>Mistake 1:<\/strong> Using basic recursion for anything bigger than fibonacci(30)<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npython\n# DON&#039;T do this for large n\nfibonacci_recursive(40)  # Will take minutes\n\n<\/pre><\/div>\n\n\n<p><strong>Mistake 2:<\/strong> Forgetting the base cases<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npython\n# This will crash\ndef bad_fibonacci(n):\n    return bad_fibonacci(n-1) + bad_fibonacci(n-2)  # No stopping condition\n\n<\/pre><\/div>\n\n\n<p><strong>Mistake 3:<\/strong> Off-by-one errors<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npython\n# Make sure you know if you want the nth number or first n numbers\nfibonacci(5)        # Returns the 5th Fibonacci number (5)\nfibonacci_sequence(5) # Returns first 5 Fibonacci numbers &#x5B;0,1,1,2,3]\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"interview-tips\">Interview Tips<\/h2>\n\n\n\n<p>When asked about Fibonacci in an interview:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Start with the simple loop solution - shows you care about performance<\/li>\n\n\n\n<li>Explain why basic recursion is bad - demonstrates you understand efficiency<\/li>\n\n\n\n<li>Mention memoization - shows advanced knowledge<\/li>\n\n\n\n<li>Ask clarifying questions: Do they want the nth number or first n numbers? Should you handle negative inputs?<\/li>\n<\/ul>\n\n\n\n<p><strong>Read:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/python-interview-questions\/\">Python Interview Questions and Answers<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/python-quiz\/\">Python MCQs Test<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/python-compiler-tool\/\">Online Python Compiler<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"quick-reference\">Quick Reference<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npython\n# Most common: get the nth Fibonacci number\ndef fibonacci(n):\n    if n &amp;lt;= 1:\n        return n\n    prev, curr = 0, 1\n    for i in range(2, n + 1):\n        prev, curr = curr, prev + curr\n    return curr\n\n# Get first n Fibonacci numbers\ndef fibonacci_sequence(n):\n    if n &amp;lt;= 0: return &#x5B;]\n    if n == 1: return &#x5B;0]\n    sequence = &#x5B;0, 1]\n    for i in range(2, n):\n        sequence.append(sequence&#x5B;i-1] + sequence&#x5B;i-2])\n    return sequence\n\n# Fast recursive version\nfrom functools import lru_cache\n@lru_cache(maxsize=None)\ndef fibonacci_recursive_fast(n):\n    if n &amp;lt;= 1: return n\n    return fibonacci_recursive_fast(n-1) + fibonacci_recursive_fast(n-2)\n\n<\/pre><\/div>\n\n\n<p>Use the simple loop version unless you have a specific reason not to. It's fast, uses little memory, and easy to debug.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"common-questions\">Common Questions<\/h2>\n\n\n\n<p><strong>Why do interviewers love this problem?<\/strong><br>They want to see your coding style, test if you understand recursion, and how you handle performance issues. Most people know about Fibonacci, so it's fair game.<\/p>\n\n\n\n<p><strong>What's the biggest Fibonacci number I can calculate?<\/strong><br>Python doesn't have integer limits like other languages. Some people have calculated Fibonacci (10000) on a laptop - it runs fast. The real limit is how long you want to wait and how much memory you have.<\/p>\n\n\n\n<p><strong>Any tricks for interviews?<\/strong><br>Start with the loop version. It shows you care about speed. Then mention why recursion is slow (it recalculates everything). Finally, explain memoization if they ask about fixing recursion. This covers all the bases.<\/p>\n\n\n\n<p><strong>What about negative numbers?<\/strong><br>There's actually a pattern: F(-n) = (-1)^(n+1) * F(n). But most interview questions stick to positive numbers. Just ask what they want you to do with edge cases.<\/p>\n\n\n\n<p><strong>Should I memorize all these approaches?<\/strong><br>No. Understand the loop version really well. Know why basic recursion is slow. Remember that caching fixes it. That's 90% of what you need for interviews.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"further-reading\"><strong>Further Reading<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/factorial-program-in-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">Factorial of a number in Python<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/palindrome-in-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">Palindrome in Python<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/convert-list-to-string-python-program\/\">Convert List to String in Python<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/eval-in-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">Eval Function in Python<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-java\/\">Fibonacci Series in Java<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-c\/\">Fibonacci Series in C<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Fibonacci Series is a pattern where any number is a sum of previous two numbers<\/p>\n","protected":false},"author":41,"featured_media":111379,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[36796],"content_type":[],"class_list":["post-12159","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-python"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Program to Print the Fibonacci Sequence<\/title>\n<meta name=\"description\" content=\"Fibonacci Series in Python: Fibonacci series is a pattern of numbers where each number is the sum of the previous two numbers.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Complete Guide to Fibonacci in Python\" \/>\n<meta property=\"og:description\" content=\"Fibonacci Series in Python: Fibonacci series is a pattern of numbers where each number is the sum of the previous two numbers.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-27T06:20:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-26T05:02:52+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1408\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/fibonacci-series-in-python\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/fibonacci-series-in-python\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Complete Guide to Fibonacci in Python\",\"datePublished\":\"2022-09-27T06:20:00+00:00\",\"dateModified\":\"2025-09-26T05:02:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/fibonacci-series-in-python\\\/\"},\"wordCount\":627,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/fibonacci-series-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/fibonacci-series-python.webp\",\"keywords\":[\"python\"],\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/fibonacci-series-in-python\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/fibonacci-series-in-python\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/fibonacci-series-in-python\\\/\",\"name\":\"Python Program to Print the Fibonacci Sequence\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/fibonacci-series-in-python\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/fibonacci-series-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/fibonacci-series-python.webp\",\"datePublished\":\"2022-09-27T06:20:00+00:00\",\"dateModified\":\"2025-09-26T05:02:52+00:00\",\"description\":\"Fibonacci Series in Python: Fibonacci series is a pattern of numbers where each number is the sum of the previous two numbers.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/fibonacci-series-in-python\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/fibonacci-series-in-python\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/fibonacci-series-in-python\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/fibonacci-series-python.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/09\\\/fibonacci-series-python.webp\",\"width\":1408,\"height\":768,\"caption\":\"Fibonacci Series in Python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/fibonacci-series-in-python\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IT\\\/Software Development\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/software\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Complete Guide to Fibonacci in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Program to Print the Fibonacci Sequence","description":"Fibonacci Series in Python: Fibonacci series is a pattern of numbers where each number is the sum of the previous two numbers.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/","og_locale":"en_US","og_type":"article","og_title":"Complete Guide to Fibonacci in Python","og_description":"Fibonacci Series in Python: Fibonacci series is a pattern of numbers where each number is the sum of the previous two numbers.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2022-09-27T06:20:00+00:00","article_modified_time":"2025-09-26T05:02:52+00:00","og_image":[{"width":1408,"height":768,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python.webp","type":"image\/webp"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Complete Guide to Fibonacci in Python","datePublished":"2022-09-27T06:20:00+00:00","dateModified":"2025-09-26T05:02:52+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/"},"wordCount":627,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python.webp","keywords":["python"],"articleSection":["IT\/Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/","url":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/","name":"Python Program to Print the Fibonacci Sequence","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python.webp","datePublished":"2022-09-27T06:20:00+00:00","dateModified":"2025-09-26T05:02:52+00:00","description":"Fibonacci Series in Python: Fibonacci series is a pattern of numbers where each number is the sum of the previous two numbers.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python.webp","width":1408,"height":768,"caption":"Fibonacci Series in Python"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/fibonacci-series-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"IT\/Software Development","item":"https:\/\/www.mygreatlearning.com\/blog\/software\/"},{"@type":"ListItem","position":3,"name":"Complete Guide to Fibonacci in Python"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python.webp",1408,768,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python-150x150.webp",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python-300x164.webp",300,164,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python-768x419.webp",768,419,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python-1024x559.webp",1024,559,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python.webp",1408,768,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python.webp",1408,768,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python-640x768.webp",640,768,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python-96x96.webp",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/09\/fibonacci-series-python-150x82.webp",150,82,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"Fibonacci Series is a pattern where any number is a sum of previous two numbers","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/12159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=12159"}],"version-history":[{"count":78,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/12159\/revisions"}],"predecessor-version":[{"id":112337,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/12159\/revisions\/112337"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/111379"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=12159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=12159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=12159"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=12159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}