?? Day 3: Fibonacci Number

?? Day 3: Fibonacci Number

?? Problem Statement:

The Fibonacci numbers, commonly denoted F(n), form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,

  • F(0) = 0, F(1) = 1
  • F(n) = F(n - 1) + F(n - 2), for n > 1.

Given n, calculate F(n).

Example 1:

Input: n = 2 - Explanation: F(2) = F(1) + F(0) = 1 + 0 = 1.

Example 2:

Input: n = 3 - Explanation: F(3) = F(2) + F(1) = 1 + 1 = 2.

Example 3:

Input: n = 4 - Explanation: F(4) = F(3) + F(2) = 2 + 1 = 3.

? Like, Share, Comment, Feedback & Subscribe for More! Feel free to share your thoughts and follow along with the challenge. Let’s learn and improve together!

?? #100DaysLeetCode #LeetCodeChallenge #Python #PythonCoding #DSA #ProblemSolving #CodingJourney #Disha100DaysChallenge



Moiz Akhtar

Ex-ipleaders || Trying to tell Stories|| Learning Content Creation|| Budding Lawyer ||

4 周

nice explanation of Fibonacci ?

回复

要查看或添加评论,请登录

Disha Khanpara的更多文章

  • ??Day 6:-Two Sum

    ??Day 6:-Two Sum

    I’m back! Took a short break, but now it’s time to get back on track. The next two weeks are all about consistency, and…

  • ??Day 5:-Water Bottles

    ??Day 5:-Water Bottles

    ?? Problem Statement: Water Bottles You have numBottles full water bottles. After drinking a bottle, it becomes empty.

    2 条评论
  • ?? Day 4: Tribonacci Number

    ?? Day 4: Tribonacci Number

    ?? Problem Statement: The Tribonacci sequence is defined as: ?? T(0) = 0, T(1) = 1, T(2) = 1 ?? T(n) = T(n - 1) + T(n -…

  • ?? Day 2: Power of Two

    ?? Day 2: Power of Two

    ?? Problem Statement: Given an integer n, return true if it is a power of two, otherwise return false. A number is a…

  • 100 Days of LeetCode: "Day 1 - Palindrome Number"

    100 Days of LeetCode: "Day 1 - Palindrome Number"

    Hello everyone! ?? Today, I’m beginning my 100 Days LeetCode Challenge and wanted to share it with you. For the next…

  • DO EPIC SHIT Book by Ankur Warikoo

    DO EPIC SHIT Book by Ankur Warikoo

    "Do Epic Shit" by Ankur Warikoo is a remarkable book brimming with invaluable life lessons. It commences with profound…

    4 条评论

社区洞察

其他会员也浏览了