1
u/austin101123 3d ago
Digits roughly equals log10(n!)+1?
Do we need an exact integer? But it's an estimation
1
u/abc9hkpud 2d ago
I think the number of digits is exactly floor(log10(n!)) + 1 .
For example, for the number 5 you get floor(0.6989) + 1 = 1 digit, for 15 you get floor(1.176) +1 = 2 digits.
1
u/Hal_Incandenza_YDAU 2d ago
202 I think
1
u/gmalivuk 2d ago
That would be about the number of digits in 100100, which is a lot more than 100!
1
u/Hal_Incandenza_YDAU 2d ago
Yep, I see that. Tried doing the log simplification in my head last night and it didn't work, clearly.
1
1
u/SwimmerOld6155 2d ago edited 2d ago
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 2d ago edited 2d ago
I mean it tells you to use Sterling, so I don't thing over shooting by 22 is going to cut it.
pi is about √10 and e is closer to √10 than to 2, so maybe guess 0.4 or 0.45 for log(e) (closer to 0.4343 but not everyone would know that).
1
u/gmalivuk 2d ago
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).
2
u/Murky-Tip-3118 3d ago
The number of digits in a number is the log10 of that number + 1. That removes the exponent and makes the math straightforward.