The number resulting from the calculation 1 × 2 × 3 × ⋯ × n has n digits.
What is the sum of all possible values of n ?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Got a proof?
Log in to reply
Well sort of... You can enumerate all the ones from 1 to 25 and see that 1, 22, 23 and 25 are the only ones that satisfy the relationship. Once you get to 25, you see that the number has a length of 26, and for all future numbers you are multiplying by more than 25, so you will be adding at least one digit every time. Therefore there are no numbers greater than 25 for which this relationship will hold.
I've added this to my solution above.
Log in to reply
And the reason for suspecting other solutions than n = 1 is that while n continually increasing by 1, the number of digits increase with the value of n . So if you would plot the number of digits of n ! with respect to n , the graph would concave up. This can explain the existence of other solutions, as well as reasoning why there aren't more solutions after 25.
It would be helpful to write a programming code to illustrate how you got these 4 numbers. After all, this is a computer science problem...
Log in to reply
@Pi Han Goh – Done. I've added that to the solution.
Log in to reply
@Geoff Pilling – Haha, I'm expecting a Python/Java solution. Not an Excel solution
Log in to reply
@Pi Han Goh – Lol... Well, sorry... For now, that's all I got! ;-)
[This is mostly the same as Geoff's solution]
Let us consider the pairs ( n , n ! ) and ( ( n + 1 ) , ( n + 1 ) ! ) . If for some n , we know that n ! has more digits than n already, then we cannot hope that ( n + 1 ) ! has lesser digits than n ! and hence, equal to ( n + 1 ) .
So, our strategy would be to search for values of i such that digits ( i ! ) = i from i = 1 onwards. Once we encounter an i such that digits ( i ! ) > i , we can quit looking because of the reason above.
So, we could use the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Problem Loading...
Note Loading...
Set Loading...
The only such numbers are 1 , 2 2 , 2 3 , and 2 4 .
1 + 2 2 + 2 3 + 2 4 = 7 0
This is because you can enumerate all the ones from 1 to 25 and see that 1, 22, 23 and 24 are the only ones that satisfy the relationship. Once you get to 25, you see that the number has a length of 26, and for all future numbers you are multiplying by more than 25, so you will be adding at least one digit every time. Therefore there are no numbers greater than 25 for which this relationship will hold.
If you would like to verify the above, you can put the numbers 1..25 in the first column of an excel spreadsheet, and then calculate how many digits the factorial of each number has with the following formula, that you can put in B1 and copy down to B25:
=CEILING(LOG(FACT(A1);10);1)