{"id":"ef18e119-2b2c-4356-9f74-aae3f9e00bfc","name":"Fibonacci-dp","description":"1. You are given a number n.\r\n2. You are required to print the nth element of fibonnaci sequence.\r\n\r\nNote -> Notice precisely how we have defined the fibonnaci sequence\r\n0th element -> 0\r\n1st element -> 1\r\n2nd element -> 1\r\n3rd element -> 2\r\n4th element -> 3\r\n5th element -> 5\r\n6th element -> 8","inputFormat":"A number n","outputFormat":"A number representing the nth element of fibonnaci sequence","constraints":"0 &lt;= n &lt;= 45","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nint fib(int n){\r\n // write your code here\r\n\r\n return 0;\r\n}\r\n\r\nint main(){\r\n int n;\r\n cin>>n;\r\n cout<<fib(n)<<endl;\r\n return 0;\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main{\r\n\r\npublic static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"python":{"code":"def fun(n ,dp):\n #write code here\n \n return 0\n\n\n\n\ndef main():\n n = int(input())\n dp = []*(n+1)\n print(fun(n, dp));\n \nif __name__ == \"__main__\":\n main()"}},"points":10,"difficulty":"easy","sampleInput":"10","sampleOutput":"55","questionVideo":"https://www.youtube.com/embed/94dfRrDANRY","hints":[],"associated":[{"id":"262b2801-6fd7-4c5d-965f-fc867cdca592","name":"fibonacci number","slug":"fibonacci-number","type":4},{"id":"9da43d83-95be-4d7b-8c87-9c037d35c525","name":"Complete the blank line to find the nth fibonacci number:","slug":"complete-the-blank-line-to-find-the-nth-fibonacci-number","type":4},{"id":"cc1f3777-3bad-4910-88a8-c575fd1f3813","name":"Time complexity of Fibonacci series is","slug":"time-complexity-of-fibonacci-series-is","type":4},{"id":"e63c4756-99a5-4e23-ad12-758007e6a3ee","name":"Fibonacci series","slug":"fibonacci-series","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"52d62581-1313-45fb-aaf0-1d72a45f6a50","name":"Dynamic Programming And Greedy For Beginners","slug":"dynamic-programming-and-greedy-for-beginners","type":0},{"id":"f82b6a2f-5b1c-447b-ae62-d552e3a8f5bb","name":"Fibonacci-dp","slug":"fibonacci-dp","type":1}],"next":{"id":"7149f098-b0a1-4a52-9f67-7ef635a31a2b","name":"Fibonacci (DP)","type":3,"slug":"fibonacci-dp"},"prev":{"id":"e062190e-71d8-4b1a-81de-f5ee043c52df","name":"D.P. Essentials","type":0,"slug":"d-p-essentials"}}}

Fibonacci-dp

1. You are given a number n. 2. You are required to print the nth element of fibonnaci sequence. Note -> Notice precisely how we have defined the fibonnaci sequence 0th element -> 0 1st element -> 1 2nd element -> 1 3rd element -> 2 4th element -> 3 5th element -> 5 6th element -> 8

{"id":"ef18e119-2b2c-4356-9f74-aae3f9e00bfc","name":"Fibonacci-dp","description":"1. You are given a number n.\r\n2. You are required to print the nth element of fibonnaci sequence.\r\n\r\nNote -> Notice precisely how we have defined the fibonnaci sequence\r\n0th element -> 0\r\n1st element -> 1\r\n2nd element -> 1\r\n3rd element -> 2\r\n4th element -> 3\r\n5th element -> 5\r\n6th element -> 8","inputFormat":"A number n","outputFormat":"A number representing the nth element of fibonnaci sequence","constraints":"0 &lt;= n &lt;= 45","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nint fib(int n){\r\n // write your code here\r\n\r\n return 0;\r\n}\r\n\r\nint main(){\r\n int n;\r\n cin>>n;\r\n cout<<fib(n)<<endl;\r\n return 0;\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main{\r\n\r\npublic static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"python":{"code":"def fun(n ,dp):\n #write code here\n \n return 0\n\n\n\n\ndef main():\n n = int(input())\n dp = []*(n+1)\n print(fun(n, dp));\n \nif __name__ == \"__main__\":\n main()"}},"points":10,"difficulty":"easy","sampleInput":"10","sampleOutput":"55","questionVideo":"https://www.youtube.com/embed/94dfRrDANRY","hints":[],"associated":[{"id":"262b2801-6fd7-4c5d-965f-fc867cdca592","name":"fibonacci number","slug":"fibonacci-number","type":4},{"id":"9da43d83-95be-4d7b-8c87-9c037d35c525","name":"Complete the blank line to find the nth fibonacci number:","slug":"complete-the-blank-line-to-find-the-nth-fibonacci-number","type":4},{"id":"cc1f3777-3bad-4910-88a8-c575fd1f3813","name":"Time complexity of Fibonacci series is","slug":"time-complexity-of-fibonacci-series-is","type":4},{"id":"e63c4756-99a5-4e23-ad12-758007e6a3ee","name":"Fibonacci series","slug":"fibonacci-series","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"52d62581-1313-45fb-aaf0-1d72a45f6a50","name":"Dynamic Programming And Greedy For Beginners","slug":"dynamic-programming-and-greedy-for-beginners","type":0},{"id":"f82b6a2f-5b1c-447b-ae62-d552e3a8f5bb","name":"Fibonacci-dp","slug":"fibonacci-dp","type":1}],"next":{"id":"7149f098-b0a1-4a52-9f67-7ef635a31a2b","name":"Fibonacci (DP)","type":3,"slug":"fibonacci-dp"},"prev":{"id":"e062190e-71d8-4b1a-81de-f5ee043c52df","name":"D.P. Essentials","type":0,"slug":"d-p-essentials"}}}
plane

Editor


Loading...

Fibonacci-dp

easy

1. You are given a number n. 2. You are required to print the nth element of fibonnaci sequence. Note -> Notice precisely how we have defined the fibonnaci sequence 0th element -> 0 1st element -> 1 2nd element -> 1 3rd element -> 2 4th element -> 3 5th element -> 5 6th element -> 8

Constraints

0 <= n <= 45

Format

Input

A number n

Output

A number representing the nth element of fibonnaci sequence

Example

Sample Input

10

Sample Output

55

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode