Given an integer N. You have to find the number of digits that appear in its factorial, where factorial is defined as, factorial(N) = 1*2*3*4..*N and factorial(0) = 1.
 
Example 1:
Input:
N = 5
Output:
3
Explanation:
5! is 120 so there are 3
digits in 120
Example 2:
Input:
N = 10
Output:
7
Explanation:
10! is 3628800 so there are
7 digits in 3628800
Your Task: 
You don't need to read input or print anything. Your task is to complete the function facDigits() which takes an integer N as input parameter and returns the number of digits in factorial of N.
 
Expected Time Complexity: O(Log(N))
Expected Space Complexity: O(1)
 
Constraints:
1 ≤ N ≤ 10^{4}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3

class Solution:

    def facDigits(self,N):

        #code here

Solutions:
import math

class Solution:

	def facDigits(self, N):
		return len(str(math.factorial(N)))


class Solution:

	def facDigits(self, N):
		import math as m
		c = str(m.factorial(N))
		return len(c)


import math

class Solution:

	def facDigits(self, N):
		if N == 0:
			return 1

		def formula(x):
			return x * math.log(x / math.e, 10) + math.log(2 * math.pi * x, 10) / 2
		return math.ceil(formula(N))


import math

class Solution:

	def facDigits(self, N):
		fact = math.factorial(N)
		a = str(fact)
		b = []
		count = 0
		for j in range(len(a)):
			count += 1
		return count


import math

class Solution:

	def facDigits(self, N):
		if N == 1:
			return 1
		count = 0
		i = 2
		while i <= N:
			count += math.log10(i)
			i += 1
		return math.ceil(count)


from math import factorial as fac

class Solution:

	def facDigits(self, N):
		choq = fac(N)
		res = [int(x) for x in str(choq)]
		return len(res)


import math

class Solution:

	def facDigits(self, N):
		n_digits = 0
		for i in range(1, N + 1):
			n_digits += math.log10(i)
		return int(n_digits) + 1


from math import floor, log10

class Solution:

	def facDigits(self, N):
		ans = 1
		for i in range(1, N + 1):
			ans = ans * i
		return floor(log10(ans)) + 1


import math

class Solution:

	def facDigits(self, N):
		if N == 0:
			return 1
		else:
			x = N * math.log10(N / math.e) + math.log10(2 * math.pi * N) / 2.0
		return int(x) + 1


import math

class Solution:

	def facDigits(self, N):
		if N == 0:
			return 1
		else:
			count = 1
			for i in range(2, N + 1):
				count += math.log(i, 10)
		return int(count)


import math

class Solution:

	def facDigits(self, N):
		fact = 1
		for i in range(N, 0, -1):
			fact *= i
		return math.floor(math.log(fact, 10) + 1)


import math

class Solution:

	def facDigits(self, N):
		if N < 0:
			return 0
		if N <= 1:
			return 1
		res = 0
		for i in range(2, N + 1):
			res = res + math.log(i, 10)
		return math.floor(res) + 1


import math

class Solution:

	def facDigits(self, N):
		fact = 1
		if N == 1 or N <= 2:
			return 1
		else:
			for i in range(2, N + 1):
				fact += math.log10(i)
			return math.floor(fact)


class Solution:

	def facDigits(self, n):
		fact = 1
		for i in range(1, n + 1):
			fact = fact * i
		return len(str(fact))


import math

class Solution:

	def facDigits(self, N):
		j = 2
		cnt = 0
		while j <= N:
			cnt += math.log10(j)
			j += 1
		return int(cnt) + 1


class Solution:

	def facDigits(self, N):
		fact = 1
		for i in range(1, N + 1):
			fact = fact * i
		x = str(fact)
		return len(x)


class Solution:

	def facDigits(self, N):
		import math
		sums = 1
		while N >= 1:
			sums = sums * N
			N -= 1
		return int(math.log10(sums) + 1)


class Solution:

	def facDigits(self, N):
		import math
		if N <= 1:
			return 1
		a = 0
		for i in range(2, N + 1):
			a += math.log10(i)
		return math.floor(a) + 1


class Solution:

	def facDigits(self, N):
		import math
		f = 1
		for i in range(2, N + 1):
			f = f * i
		return int(math.log10(f)) + 1


class Solution:

	def facDigits(self, N):
		f = 1
		for i in range(1, N + 1):
			f *= i
		return len(str(f))


class Solution:

	def facDigits(self, N):
		if N == 0:
			return 1
		else:
			ans = 1
			for i in range(1, N + 1):
				ans *= i
			return len(str(ans))


import math

class Solution:

	def facDigits(self, N):
		if N < 1:
			return 0
		if N == 0 or N == 1:
			return 1
		a = math.factorial(N)
		return len(str(abs(a)))


import math

class Solution:

	def facDigits(self, N):
		sum = 0
		for i in range(1, N + 1):
			sum += math.log10(i)
		return math.floor(sum) + 1


import math

class Solution:

	def facDigits(self, N):
		count = 0
		a = str(math.factorial(N))
		for i in a:
			count += 1
		return count


import math as m

class Solution:

	def facDigits(self, N):
		count = 0
		factorial = 1
		for i in range(1, N + 1):
			factorial = factorial * i
		n = factorial
		count = int(m.log10(n) + 1)
		return count


import math

class Solution:

	def facDigits(self, N):
		l = math.factorial(N)
		return int(math.log(l, 10) + 1)


import math

class Solution:

	def facDigits(self, N):
		if N == 0:
			return 1
		if N == 1:
			return 1
		fact = 1
		for i in range(2, N + 1):
			fact *= i
		dig = int(math.log(fact, 10)) + 1
		return dig


import math

class Solution:

	def facDigits(self, N):
		ans = 1
		i = 0
		while i < N:
			ans = ans * (i + 1)
			i += 1
		return math.floor(math.log(ans, 10) + 1)


from math import log10, e, pi, sqrt

class Solution:

	def facDigits(self, N):
		if N == 1 or N == 0:
			return N
		return int(N * log10(N / e) + log10(2 * pi * N) / 2) + 1


from math import log10

class Solution:

	def facDigits(self, N):
		if N == 1 or N == 0:
			return N
		numDigits = 0
		for i in range(2, N + 1):
			numDigits += log10(i)
		return int(numDigits + 1)


import math

class Solution:

	def facDigits(self, N):
		if N < 0:
			return 0
		if N <= 1:
			return 1
		res = 0
		for i in range(2, N + 1):
			res += math.log10(i)
		return math.floor(res) + 1
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.facDigits(N))


import math

class Solution:

	def facDigits(self, N):
		r = 1
		for i in range(1, N + 1):
			r = r * i
		return math.floor(math.log(r, 10) + 1)
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.facDigits(N))


import math

class Solution:

	def facDigits(self, N):
		r = 1
		for i in range(1, N + 1):
			r = r * i
		return math.ceil(math.log(r, 10))


class Solution:

	def facDigits(self, N):
		import math

		def findDigits(n):
			if n < 0:
				return 0
			if n <= 1:
				return 1
			x = n * math.log10(n / math.e) + math.log10(2 * math.pi * n) / 2.0
			return math.floor(x) + 1
		return findDigits(N)


import math

class Solution:

	def facDigits(self, N):
		f = 1
		for i in range(2, N + 1):
			f = f * i
		return math.floor(math.log(f, 10) + 1)


import math

class Solution:

	def facDigits(self, N):
		if N < 0:
			return 0
		if N <= 1:
			return 1
		digits = N * math.log10(N / math.e) + math.log10(2 * math.pi * N) / 2
		return math.floor(digits) + 1


import math

class Solution:

	def facDigits(self, N):
		answer = 1
		for i in range(1, N + 1):
			answer *= i
		return math.floor(math.log10(answer) + 1)


import math

class Solution:

	def facDigits(self, N):
		if N < 0:
			return 0
		if N == 1 or N == 0:
			return 1
		r = 1
		for i in range(1, N + 1):
			r = r * i
		return math.floor(math.log(r, 10) + 1)


from math import log10, floor

class Solution:

	def facDigits(self, N):
		digits = 0
		if N < 0:
			return 0
		elif N == 0:
			return 1
		else:
			for i in range(2, N + 1):
				digits += log10(i)
			return floor(digits) + 1


import math

class Solution:

	def facDigits(self, N):
		s = math.factorial(N)
		k = [int(i) for i in str(s)]
		return len(k)


import math

class Solution:

	def facDigits(self, n):
		if n < 0:
			return 0
		if n <= 1:
			return 1
		digits = 0
		for i in range(2, n + 1):
			digits += math.log10(i)
		return math.floor(digits) + 1


import math

class Solution:

	def facDigits(self, n):
		if n < 0:
			return 0
		if n <= 1:
			return 1
		digits = 0
		for i in range(2, N + 1):
			digits += math.log(i, 10)
		return int(digits) + 1