Skip to content

Commit 6b9b29c

Browse files
committed
update
1 parent 396f2ce commit 6b9b29c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed
16.4 KB
Loading

content/trailing-zeros-factorial-python.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ Number of trailing zeros in the factorial of an integer
66
:slug: trailing-zeros-factorial
77
:summary: Use Python to find the number of trailing zeros in the factorial of an integer
88

9-
Please note, the math expressions are broken. I will be fixing it soon.
10-
119
Hi all, I recently learned about a cool formula to calculate the number of
1210
trailing zeros in the factorial of a number. It has been a while since I
1311
wrote a program to do something like this. So, I decided to change that and
14-
write this blog post. In the spirit of wring various "calculators", we will
12+
write this blog post.
13+
14+
In the spirit of wring various "calculators", we will
1515
write a "number of trailing zero" calculator. First up though, let's refresh
1616
some key relevant concepts.
1717

@@ -28,10 +28,12 @@ and that of 3.5 is 3 and the floor of 3 is 3 as well.
2828
Now, coming back to the focus of this post, this document at brilliant.org wiki
2929
explains the process in `detail <https://brilliant.org/wiki/trailing-number-of-zeros/>`__.
3030

31-
The key bit there in is this formula: :math:`\sum_{i=0}^{k}\floor*{\frac{n}{5^i}}`
31+
The key bit there in is this formula:
32+
33+
.. figure:: {filename}/images/trailing_zeros_formula.png
34+
3235

33-
where, ``n`` is the number for whose factorial we want to find the number of trailing zeros in and ``k``
34-
is defined as:
36+
where, ``n`` is the number for whose factorial we want to find the number of trailing zeros.
3537

3638
The following Python program implements the above formula:
3739

0 commit comments

Comments
 (0)