Given a number N, find the number of digits in the Nth Fibonacci Number.
 
Example 1:
Input:
N = 5
Output:
1
Explanation:
5th fibonacci number is 5
which contains only one digit
Example 2:
Input:
N = 12
Output:
3
Explanation:
12th fibonacci number is 144
which contains three digits
Your Task:
You don't need to read input or print anything. Your task is to complete the function noOfDigits() which takes an integer N as input parameters and returns an integer, number of digits in Nth Fibonacci number
 
Expected Time Complexity: O(1)
Expected Space Complexity: O(1)
 
Constraints:
1 <= N <= 10^{3}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:
    def noOfDigits(self, N):
        # code here

Solutions:
class Solution:

	def noOfDigits(self, N):
		a = 0
		b = 1
		c = a + b
		for i in range(1, N):
			c = a + b
			a = b
			b = c
		return len(str(c))


class Solution:

	def noOfDigits(self, N):
		F = [0, 1]
		for i in range(2, N + 1):
			F.append(F[i - 1] + F[i - 2])
		ans = str(F[N])
		return len(ans)


import math

class Solution:

	def noOfDigits(self, N):
		phi = (1 + math.sqrt(5)) / 2
		if N == 1:
			return 1
		return math.ceil(N * math.log(phi, 10) - 0.5 * math.log(5, 10))


class Solution:

	def noOfDigits(self, N):
		fab = [1, 1]
		for i in range(2, N):
			fab.append(fab[-1] + fab[-2])
		s = str(fab[-1])
		return len(s)


class Solution:

	def noOfDigits(self, N):
		t1 = 1
		t2 = 1
		i = 2
		while i <= N:
			t3 = t1 + t2
			t1 = t2
			t2 = t3
			i += 1
		return len(str(t1))