Exercise · Volume 1 · 1.2.5-4
Exercise 1.2.5-4
proved in Lean solution written
| Rating | 13 |
|---|---|
| Markers | recommended |
| Kind | K3, find a value: compute a number, a set or a closed form from the written solution |
| Section | Section 1.2.5 of Volume 1. Companion chapter: Permutations and factorials |
The task
From the value of , find the number of decimal digits of , 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 has digits. The first digit comes from the fraction part of the logarithm.
Hint 2
Compute to get the leading digits. For the last digit, ask whether is divisible by , and use eq. (8).
Solution
Show the solution
Let .
Digits. The number of digits is .
First digit. . The given value fixes the fraction part as , between and . Then and , so the leading part is and the first digit is .
Last digit. By eq. (8) the exponent of in is . The exponent of is larger. So divides , and the last digit is (there are exactly 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: , so has 158 digits and starts with .
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 and . 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.
- Problem (a):
TAOCP.S1_2_5.Ex4.a.statementaxioms: Classical.choice, Quot.sound, propext - Solution (a):
TAOCP.S1_2_5.Ex4.a.solvedaxioms: Classical.choice, Quot.sound, propext - Problem (b):
TAOCP.S1_2_5.Ex4.b.statementaxioms: Classical.choice, Quot.sound, propext - Solution (b):
TAOCP.S1_2_5.Ex4.b.solvedaxioms: Classical.choice, Quot.sound, propext - Problem (c):
TAOCP.S1_2_5.Ex4.c.statementaxioms: none - Solution (c):
TAOCP.S1_2_5.Ex4.c.solvedaxioms: none
The status is computed from the Lean build. The node of the map.
Something is wrong? Report it.