Post Reply 
(49g 50g) Number of Trailing Zeros in N!
06-03-2022, 02:03 AM
Post: #2
RE: (49g 50g) Number of Trailing Zeros in N!
We can also use the recurrence:

a(n) = floor(n/5) + a(floor(n/5));

This program is for the HP-42S but should work with most other models as well:
Code:
00 { 14-Byte Prgm }
01 0
02 X<>Y
03▸LBL 00
04 5
05 ÷
06 IP
07 +
08 LASTX
09 X>0?
10 GTO 00
11 R↓
12 END

This program is for the HP-48:
Code:
\<< 0
    WHILE SWAP DUP
    REPEAT
        5 / IP
        DUP ROT +
    END
    DROP
\>>

Example

\(
\begin{align}
n &= 7392 \\
\\
a(n) &= 1478 + 295 + 59 + 11 + 2 \\
&= 1845 \\
\end{align}
\)

References

Quote:Gardner, M. "Factorial Oddities." Ch. 4 in Mathematical Magic Show: More Puzzles, Games, Diversions, Illusions and Other Mathematical Sleight-of-Mind from Scientific American. New York: Vintage, pp. 50-65, 1978

Thank you for reminding me of this book.
I got the German translation "Mathematische Hexereien" as a teenager.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (49g 50g) Number of Trailing Zeros in N! - Thomas Klemm - 06-03-2022 02:03 AM



User(s) browsing this thread: 1 Guest(s)