Given a number N. The task is to find the total Number of Digits in .
Input: N = 3 Output: 3 If N=3, (3!)3=216, So the count of digits is 3 Input: N = 4 Output: 6
As we know, log(a*b) = log(a) + log(b) Consider, X = log(N!) = log(1*2*3....... * N) = log(1)+log(2)+........ +log(N)
Now, we know that the floor value of log base 10 increased by 1, of any number, gives the number of digits present in that number. That is, number of digits in a number say N will be floor(log10N) + 1.
Therefore, number of digit in will be:
floor(log())+1 = floor(N*log10(N!)) + 1 = floor(N*X) + 1.
Below is the implementation of the above approach:
Rated as one of the most sought after skills in the industry, own the basics of coding with our C++ STL Course and master the very concepts by intense problem-solving.
- Total ways of choosing X men and Y women from a total of M men and W women
- Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
- Minimum digits to be removed to make either all digits or alternating digits same
- Find the total count of numbers up to N digits in a given base B
- Total number of non-decreasing numbers with n digits
- Count total number of N digit numbers such that the difference between sum of even and odd digits is 1
- Count total number of digits from 1 to n
- Find the Largest number with given number of digits and sum of digits
- Find smallest number with given number of digits and sum of digits under given constraints
- Total numbers with no repeated digits in a range
- Find the average of k digits from the beginning and l digits from the end of the given number
- Number of digits in the nth number made of given four digits
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Number formed by deleting digits such that sum of the digits becomes even and the number odd
- Find the total number of composite factor for a given number
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Maximize the given number by replacing a segment of digits with the alternate digits given
- Check if the sum of digits of number is divisible by all of its digits
- Sum of the digits of square of the given number which has only 1's as its digits
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.