Timer is Running

nth digit of Fibonacci
Submissions: 9   Accuracy:


  Difficulty: Basic   Marks: 1

A Fibonacci series (starting from 1) written in order without any spaces in between, thus producing a sequence of digits. Find the nth digit in the sequence.

Example 1:

Input: n = 3
Output: 2 
Explanation: 3rd digit of fibonacci 
series is 2(1123.....).

Example 2:

Input: n = 7
Output: 1
Explanation: 7th digit of fibonacci
series is 1(11235811.....).

Your Task:  
You dont need to read input or print anything. Complete the function nthFibonacciDigit() which takes n as input parameter and returns nth digit of fabonacci series. 

Expected Time Complexity: O(n
Expected Auxiliary Space: O(n)

1<= n <=100

** For More Input/Output Examples Use 'Expected Output' option **

Author: atharv

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.