DAYS
HOUR
MINS
SEC
Error
Calculate the Nth digit in the representation of Pi.
Example 1:
Input: N = 1 Output: 3 Explanation: Value of Pi is 3.14... So, the first digit is 3.
Example 2:
Input: N = 2 Output: 1 Explanation: Value of Pi is 3.14... So, the second digit is 1.
Your Task:
You don't need to read input or print anything. Your task is to complete the function nthDigOfPi() which takes an Integer N as input and returns the Nth digit of Pi.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 <= N <= 104
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes