taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.2.5-4

Exercise 1.2.5-4

proved in Lean solution written

Rating13
Markersrecommended
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.2.5 of Volume 1. Companion chapter: Permutations and factorials

The task

From the value of log⁡101000!\log_{10} 1000!, find the number of decimal digits of 1000!1000!, its first digit and its last digit.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

A number N≥1N \ge 1 has ⌊log⁡10N⌋+1\lfloor \log_{10} N \rfloor + 1 digits. The first digit comes from the fraction part of the logarithm.

Hint 2

Compute 100.6046410^{0.60464} to get the leading digits. For the last digit, ask whether 1000!1000! is divisible by 1010, and use eq. (8).

Solution

Show the solution

Let L=log⁡101000!=2567.60464…L = \log_{10} 1000! = 2567.60464\ldots.

Digits. The number of digits is ⌊L⌋+1=2567+1=2568\lfloor L \rfloor + 1 = 2567 + 1 = 2568.

First digit. 1000!=10L=102567⋅100.60464…1000! = 10^{L} = 10^{2567} \cdot 10^{0.60464\ldots}. The given value fixes the fraction part as 0.60464…0.60464\ldots, between 0.6046350.604635 and 0.6046450.604645. Then 100.604635=4.0237…10^{0.604635} = 4.0237\ldots and 100.604645=4.0239…10^{0.604645} = 4.0239\ldots, so the leading part is 4.02…4.02\ldots and the first digit is 44.

Last digit. By eq. (8) the exponent of 55 in 1000!1000! is ⌊1000/5⌋+⌊1000/25⌋+⌊1000/125⌋+⌊1000/625⌋=200+40+8+1=249\lfloor 1000/5 \rfloor + \lfloor 1000/25 \rfloor + \lfloor 1000/125 \rfloor + \lfloor 1000/625 \rfloor = 200 + 40 + 8 + 1 = 249. The exponent of 22 is larger. So 1024910^{249} divides 1000!1000!, and the last digit is 00 (there are exactly 249249 zeros at the end).

Check

Python: len(str(math.factorial(1000))) is 2568, str(math.factorial(1000))[:6] is 402387, and the last digit is 0. The same run counts 249 trailing zeros. A small test of the digit rule: log⁡10100!=157.97\log_{10} 100! = 157.97, so 100!100! has 158 digits and starts with 100.97=9.310^{0.97} = 9.3.

Remarks

The first digit needs only the first 3 or 4 decimals of the logarithm. A first digit can be read from a given logarithm only if its fraction is not too near a digit boundary, here log⁡104=0.60206\log_{10} 4 = 0.60206 and log⁡105=0.69897\log_{10} 5 = 0.69897. The trailing zeros are an instance of Legendre's rule, eq. (8) and exercise 1.2.5-12.

This solution is checked, and a person has not reviewed it yet. The source.

In Lean

proved The statement and its proof are in Lean. The kernel accepts the proof, and it uses the standard axioms only. Lean states the parts one by one.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.