File: root - text - article - 2020 - 01 - nth-fibonacci-number.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 573 Views, 25101 Search Bots | 97 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 573 Views, 25101 Search Bots | 97 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by Apple:
The Fibonacci sequence is the integer sequence defined by the recurrence relation: F(n) = F(n-1) + F(n-2), where F(0) = 0 and F(1) = 1. In other words, the nth Fibonacci number is the sum of the prior two Fibonacci numbers. Below are the first few values of the sequence:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144...
Given a number n, print the n-th Fibonacci Number.
Examples:
Input: n = 3
Output: 2
Input: n = 7
Output: 13
Here's a starting point:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 573 Views, 25101 Search Bots | 97 Words The Fibonacci sequence is the integer sequence defined by the recurrence relation: F(n) = F(n-1) + F(n-2), where F(0) = 0 and F(1) = 1. In other words, the nth Fibonacci number is the sum of the prior two Fibonacci numbers. Below are the first few values of the sequence:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144...
Given a number n, print the n-th Fibonacci Number.
Examples:
Input: n = 3
Output: 2
Input: n = 7
Output: 13
Here's a starting point:
class Solution():
def fibonacci(self, n):
# fill this in.
n = 9
print(Solution().fibonacci(n))
# 34
Related Articles
- Daily Interview Problem: Maximum Profit From Stocks
- Daily Interview Problem: Min Range Needed to Sort
- Daily Interview Problem:Create a balanced binary search tree
- Algorithm Interview: Subarray With Target Sum
- Daily Interview Question: Longest Sequence with Two Unique Numbers
- Spreadsheet Column Title
- Daily Interview Puzzle: Minimum Size Subarray Sum
- Daily Interview Problem: Distribute Bonuses
- Algorithm Interview: No Adjacent Repeating Characters
- Daily Interview Problem: Given two arrays, write a function to compute their intersection.
©2006~2024 SteakOverCooked - 0.01295 Seconds(s) - 1521.426 KB/s - 24 Online Memory: 492 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !