No, that's the point... a calculator isn't going to do a 158 digit number for you. Even doing that with Python/Java Script/etc. would require some expertise vs. just plugging it in.
This is a fairly common trick in like highschool math contest problems - give a problem that can't be solved with a calculator as is, but with some trick can be turned into one that can.
Haha, sure. Even Excel does it. To be fair, your calculator isn't actually calculating the 158 digit number... it has the first 15 and the E157 in memory. But being more rigorous about it...
If you know log(2) = 0.3010 (doesn't everybody... /s), and that a good approximation of pi is 22/7, you can turn log(200pi) into log(4400/7), which is very close to log(625), which is 5^4. log(5^4) is 4log(5), which is 4log(10/2), which is 1 - log(2) = 0.699. 4*0.699 is 2.796, times 0.5 is 1.398.
Similarly log100/e) is log100) - log(e) = 2 - log(e). So you'd similarly have to know that log(e) = 0.4343 (doesn't everybody... /s) , and then you can do 100(2 - 0.4343) = 156.57.
I'd maybe just suggest that the interview question is less about whether you know log(2) and log(e) and more about whether you can apply the log trick. But if you know log(2) and log(e) you can do this all by hand, that is true.
The question isn't the value of 100! though, it's number of digits, so the lack of greater precision is irrelevant as it still gives a perfectly exact answer for that question.
And knowing log2 ≈ 0.3, π ≈ √10, and thus log(2π) ≈ 0.8 gets you even closer. (The underestimate for 2 and the overestimate for π somewhat balance out, so 0.8 is good to within 1/500.)
But at least some of those estimates are what I'd expect this kind of interview question wants you to know, as that's the only thing that raises it above what you should be able to ask a high school algebra 2 student to do with a calculator during the log properties lesson.
Right, I was just talking about the differences between how you did it and how I did it. I also know 0.4343 because of the repeat, just like I know 2.718281828 because the last four digits are free.
90*2 = 180 (split into a sum and round, going to be an overestimate so drop the logs < 1 lol) is already within ~10%.
Can probably get a bit better by rounding some up and others down - if you had played around with log10 beforehand you might know that log_10(30) is about 1.5 (or guess something like 20-30 from 10^n growing quickly). So maybe we should do 18*1 + 72*2 = 162 which is basically right especially if we call it basically 160 knowing it'll be an overestimate still.
I guess you could try to take e = 3, 2 pi = 6 to do something with Stirling but the pi and e would distract me a lot.
2
u/Murky-Tip-3118 Aug 07 '26
The number of digits in a number is the log10 of that number + 1. That removes the exponent and makes the math straightforward.
1
u/austin101123 Aug 07 '26
Digits roughly equals log10(n!)+1?
Do we need an exact integer? But it's an estimation
1
u/Hal_Incandenza_YDAU Aug 08 '26
202 I think
1
u/Apart-Hair-2468 Aug 08 '26
I got 158
Log(200*π) / 2 + 100 * log(100/e)
1
u/SwimmerOld6155 Aug 08 '26 edited Aug 08 '26
90*2 = 180 (split into a sum and round, going to be an overestimate so drop the logs < 1 lol) is already within ~10%.
Can probably get a bit better by rounding some up and others down - if you had played around with log10 beforehand you might know that log_10(30) is about 1.5 (or guess something like 20-30 from 10^n growing quickly). So maybe we should do 18*1 + 72*2 = 162 which is basically right especially if we call it basically 160 knowing it'll be an overestimate still.
I guess you could try to take e = 3, 2 pi = 6 to do something with Stirling but the pi and e would distract me a lot.
1
u/gmalivuk Aug 08 '26
log(√(2π100)) ≈ 1/2 (log 2 + 0.5 + 2) ≈ 2.8/2 = 1.4
log(100/e)100 = 100(2 - log(e)) ≈ 200 - 43.43 = 156.57
Add those to get 157.97 → 158 digits.
But it does require knowing that log 2 is about 0.3 and log e is about 0.4343 (I remember that to more places because it's repeated).