Two  Irrational  Numbers  That  Give  the  Last  Non-Zero  Digits  of
n!  and  n
n
.
Gregory  P.  Dresden
Washington  &  Lee  University
Lexington,  VA  24450
Authors   Note:   This   is   a  slightly  revised  version  of   the   article   that   appeared  in  print   in
Mathematics  Magazine   in 2001.   The original proof of Theorem 2 was incorrect;  Ive xed that
mistake  here.   My  thanks  to  Antonio  M.  Oller-Marcen  and  Jose  Mara  Grau  for  pointing  out  the
error.   Also,  a  sequel  to  this  paper  appeared  in  2008.
We  begin  by  looking  at  the  pattern  formed  from  the  last  (i.e.  unit)  digit  of  n
n
.
Since  1
1
=  1,   2
2
=  4,   3
3
=  27,   4
4
=  256,   and  so  on,   we  can  easily  calculate  the
rst  few  numbers  in  our  pattern  to  be  1, 4, 7, 6, 5, 6, 3, 6 . . ..   We  construct  a  decimal
number N  = 0.d
1
d
2
d
3
. . . d
n
. . . such that the n
th
digit d
n
  of N  is the last (i.e. unit)
digit of n
n
; that is, N  = 0.14765636 . . ..   In a recent paper [1], R. Euler and J. Sadek
showed  that  this  N  is  a  rational  number  with  a  period  of  twenty  digits:
N  = 0.14765636901636567490.
This is a nice result,  and we might well wonder if it can be extended.   Indeed,  Euler
and Sadek in [1] recommend looking at the last non-zero digit of n! (If we just looked
at  the  last  digit  of  n!,  we  would  get  a  very  dull  pattern  of  all  0s,  as  n!  ends  in  0  for
every  n  5.)
With this is mind, lets dene lnzd(A) to be the last nonzero digit of the positive
integer  A;   it  is  easy  to  see  that  lnzd(A)  =  A/10
i
mod  10,   where  10
i
is  the  largest
power  of  10  that  divides  A.   We  wish  to  investigate  not  only  the  pattern  formed  by
lnzd(n!), but also the pattern formed by lnzd(n
n
).   In accordance with [1], we dene
the  factorial  number  F  =  0.d
1
d
2
d
3
. . . d
n
. . .   to  be  the  innite  decimal   such  that
each  digit  d
n
  = lnzd(n!),  and  we  dene  the  power  number  P  = 0.d
1
d
2
d
3
. . . d
n
. . .
to  be  the  innite  decimal   such  that  each  digit  d
n
  =  lnzd(n
n
),   and  we  ask  whether
these  numbers  are  rational  (i.e.  are  eventually-repeating  decimals)  or  irrational.
Although  the  title  of   this  article  gives  away  the  secret,   wed  like  to  point  out
that  at  rst  glance,   our  factorial  number  F  exhibits  a  suprisingly  high  degree  of
Dresden   2
regularity,   and  a  fascinating  pattern  occurs.   The  rst  few  digits  of   F  are  easy  to
calculate:
1!   =   1
2!   =   2
3!   =   6
4!   =   24
5!   =   120
6!   =   720
7!   =   5040
8!   =   40320
9!   =   362880 . . .
10!   =   3628800
11!   =   39916800
12!   =   479001600
13!   =   6227020800
14!   =   87178291200
...
Reading  the  underlined  digits,  we  have:
F  = 0.1264  22428  88682 . . .
Continuing  along  this  path,  we  have  (to  forty-nine  decimal  places):
F  = 0.1264  22428  88682  88682  44846  44846  88682  22428  22428  66264 . . .
It  is  not  hard  to  show  that  (after  the  rst  four  digits)  F  breaks  up  into  ve-digit
blocks  of  the  form  x  x  2x  x  4x,  where  x  {2, 4, 6, 8},  and  the  2x  and  4x  are  taken
mod 10.   Furthermore, if we represent these ve-digit blocks by symbols (
2 for 22428,
4  for  44846,
  
6  for  66264,
  
8  for  88682,  and
  
1  for  the  initial  four-digit  block  of  1264),
we  have:
F  = 0.
1
  
2
  
8
  
8
  
4
  
4
  
8
  
2
  
2
  
6   . . .
Grouping  these  symbols  into  blocks  of  ve  and  then  performing  more  calculations
(with  the  aid  of  Maple)  give  us  F  to  249  decimal  places:
F  = 0.
4
  
4
6
  
2
8
  
4
6
  
4
6
  
8
2
  
2
8
  
6
4
  
2
8
  
2
8   . . .
The reader will notice additional patterns in these blocks of ve symbols (twenty-ve
digits).   In  fact,   such  patterns  exist  for  any  block  of  size  5
i
.   However,   a  pattern  is
dierent  from  a  period,  and  doesnt  imply  that  our  decimal  F  is  rational.   Consider
the classic example of 0.1 01 001 0001 00001 000001  . . ., which has an obvious pattern
but  is  obviously  irrational.   It  turns  out  that  our  decimal  F  is  also  irrational,  as  the
following  theorem  indicates:
Theorem  1.   Let   F  =  0.d
1
d
2
d
3
. . . d
n
. . .   be  the  innite  decimal   such  that   each
digit  d
n
  = lnzd(n!).   Then,  F  is  irrational.
Dresden   3
As  for  our  power  number  P,   it  too  might  seem  to  be  rational  at  rst  glance.
P  is  only  slightly  dierent  from  Euler  and  Sadeks  rational  number  N,  as  seen  here:
N   =   0.14765  63690  16365  67490  14765  63690  16365  67490 . . .
and   P   =   0.14765  63691  16365  67496  14765  63699  16365  67496 . . .
(Again,   calculations   were   performed  by  Maple.)   Despite   this   striking  similarity
between  P  and  N,  it  turns  out  that  P,  like  F,  is  irrational:
Theorem  2.   Let   P  =  0.d
1
d
2
d
3
. . . d
n
. . .   be  the  innite  decimal   such  that   each
digit  d
n
  = lnzd(n
n
).   Then,  P  is  irrational.
Before  we  begin  with  the  (slightly  technical)  proofs,   let  us  pause  and  see  if  we
can  get  a  feel   for  why  these  two  numbers  must  be  irrational.   There  is  no  doubt
that  both  F  and  P  are  highly  regular,   in  that  both  exhibit  a  lot  of   repetition.
The  problem  is  that  there  are  too  many  patterns  in  the  digits,   acting  on  dierent
scales.   Taking  P,   for  example,   we  note  that  there  is  an  obvious  pattern  (as  shown
by  Euler   and  Sadek  in  [1])   repeating  every  20  digits   with  1
1
,   2
2
,   3
3
, . . . , 9
9
and
11
11
, 12
12
, . . . , 19
19
,   but  this  is  broken  by  a  similar  pattern  for  10
10
, 20
20
, . . . , 90
90
and  110
110
. . . 190
190
,   which  repeats  every  200  digits.   This,   in  turn,   is  broken  by
another  pattern  repeating  every  2000,   and  so  on.   A  similar  behaviour  is  found  for
F,  but  in  blocks  of  5,  25,  125,  and  so  on,  as  mentioned  above.   So,  in  vague  terms,
there  are  always  new  patterns  starting  up  in  the  digits  of  P  and  of  F,  and  this  is
what  makes  them  irrational.
Are  there  some  simple  observations   that   we  can  make  about   P  and  F  which
might  help  us  to  prove  our  theorems?   To  start  with,   we  might  notice  that  every
digit  of  F  (except  for  the  rst  one)  is  even.   Can  we  prove  this?   Yes,   and  without
much  diculty:
Lemma  1.   For  n  2,  then  lnzd(n!)  is  in {2, 4, 6, 8}.
Proof:   The lemma is certainly true for n = 2, 3, 4.   For n  5, we note that the prime
factorization of n! contains more 2s than 5s,  and thus even after taking out all the
10s in n!, the quotient will still be even.   To be precise, the number of 5s in n! (and
thus  the  number  of   trailing  zeros  in  its  base-10  representation)  is  e
5
  =
i=1
n/5
i
,
which  is  strictly  less  than  the  number  of   2s,   e
2
  =
i=1
n/2
i
  (here,   []   represents
the greatest integer function).   Hence,  n!/10
e
5
is an even integer not divisible by 10,
and so lnzd(n!) = n!/10
e
5
mod  10, which must be in {2, 4, 6, 8}.   This completes the
Dresden   4
proof.
Another   helpful   observation  is   to  note   that   the   lnzd  function  appears   to  be
multiplicative.   For  example,
lnzd(12)  lnzd(53) = 2  3   = 6,
and   lnzd(12  53) = lnzd(636)   = 6.
However,  we  note  that  at  times  this  rule  fails:
lnzd(15)  lnzd(22) = 5  2   = 10,
yet   lnzd(15  22) = lnzd(330)   = 3.
So,   we  can  only  prove  a  limited  form  of   multiplicativity,   but  it  is  useful   none  the
less:
Lemma  2.   Suppose  a, b  are  integers  such  that  lnzd(a) =  5,   lnzd(b) =  5.   Then,
lnzd  is  multiplicative;  that  is,  lnzd(a  b) = lnzd(a)  lnzd(b)  mod  10.
Proof:   Let  x
  denote  the  integer  x  without  its  trailing  zeros;   that  is,   x
  =  x/10
i
,
where  10
i
is  the  largest  power  of  10  dividing  x.   (Note  that  lnzd(x)  =  x
  mod  10.)
By  hypothesis,   a
  and  b
  are  both =  0  mod  5,   and  so  (a  b)
 =  0  mod  5  and  so
(a  b)
  = a
.   Thus,
lnzd(a  b)   =   lnzd((a  b)
) = lnzd(a
) = a
  mod  10
=   (a
  mod  10)  (b
  mod  10) = lnzd(a
)  lnzd(b
) = lnzd(a)  lnzd(b).
This  completes  the  proof.
We  are  now  ready  to  supply  the  proof  of  Theorem  1,   in  which  we  show  that  F
is  irrational.   The  proof   is  a  little  technical,   but  it  relies  rst  on  assuming  that  F
has a repeating decimal expansion,  then on choosing an appropriate multiple of the
period 
0
  and choosing an appropriate digit d,  in order to arrive at a contradiction.
Proof   of   Theorem  1:   We  argue  by  contradiction.   Suppose  F  is  rational.   Then  F
is  eventually  periodic;   let  
0
  be  the  period  (i.e.   for  every  n  suciently  large,   then
d
n
  = d
n+
0
).   Write  
0
  = 5
i
 K  such  that  5| K  (we  acknowledge  that  K  could  be  1)
and  let   = 2
i
 
0
  = 10
i
 K.   Then,  lnzd() = lnzd(K),  and  since  5| K,  then  10| K
and  so  lnzd(K)  =  K  mod  10.   Note  also  that  lnzd(2)  =  2K  mod  10.   Choose  M
suciently large so that both of the following are true:   lnzd(10
M
+) = lnzd() (this
can easily be done by demanding that 10
M
> ), and for all n  M, then d
n
  = d
n+
0
,
which of course would then equal d
n+
.   Finally, let d = lnzd((10
M
1)!).   By Lemma
1,  d  {2, 4, 6, 8},  and since 10
M
! = (10
M
1)!  10
M
,  then d also equals lnzd(10
M
!).
Dresden   5
Since    is   a  multiple  of   the  period  
0
,   then  if   we  let   A  =  10
M
 1 +   and
B  = 10
M
 1 + 2,  then:
d   =   lnzd((10
M
 1)!) = lnzd(A!) = lnzd(B!)
and   d   =   lnzd(10
M
!) = lnzd((A+ 1)!) = lnzd((B + 1)!)
Lets  now  look  at  the  last  two  terms  in  the  above  equation;   it  is  here  we  will   nd
our  contradiction.   Note  that  since  lnzd(A!)  =  d,   then  lnzd(A!) =  5.   Also,   since
lnzd(A+1) = lnzd(10
M
+) = lnzd() = K  mod 10, we know that lnzd(A+1) = 5.
Thus,  we  can  apply  Lemma  2  to  lnzd(A!  (A+ 1))  to  get:
d = lnzd((A+ 1)!) = lnzd(A!)  lnzd(A+ 1) = d  K  mod  10.
Likewise,  working  with  B,  we  nd:
d = lnzd((B + 1)!) = lnzd(B!)  lnzd(B + 1) = d  2K  mod  10.
Combining  these  two  equations,  we  get:
d = dK  mod  10   d = 2dK  mod  10,
and  this  becomes  d(1  K)  =  0  =  d(1  2K)  mod  10.   Since  d  is  even,   this  implies
that 1 K  = 0 mod 5 and 1 2K  = 0 mod 5, which is a contradiction.   Thus, there
can  be  no  period  
0
  and  so  F  is  irrational.   This  completes  the  proof.
We now turn our attention to the power number P derived from the last non-
zero  digits  of  n
n
.   This  part  was  more  dicult,  but  a  major  step  was  the  discovery
that  the  sequence  lnzd(100
100
),   lnzd(200
200
),   lnzd(300
300
) . . .   was  the  same  as  the
sequence lnzd(100
4
), lnzd(200
4
), lnzd(300
4
) . . ..   This relies not only on the fact that
4|100  but  also  on  the  fact  that  a
b
= a
b+4
mod  10  for  b > 0,  as  used  in  the  following
lemma:
Lemma  3.   Suppose  100 | x.   Then,  lnzd(x
x
) = (lnzd  x)
4
mod  10.
Proof:   As in Lemma 2,  let x
  denote the integer x without its trailing zeros;  that is,
x
  = x/10
i
,  where  10
i
is  the  largest  power  of  10  dividing  x.   Now,
lnzd(x
x
)   =   lnzd((10
i
x
)
10
i
x
)
=   lnzd((10
i10
i
x
)(x
)
10
i
x
)
=   lnzd((x
)
10
i
x
).
Since  10| x
,  then  10| (x
)
10
i
x
,  and  so:
lnzd(x
x
) = (x
)
10
i
x
mod  10.
Dresden   6
Since  100 |  x,   then  4 |  10
i
 x
,   and  since  (x
)
n
=  (x
)
n+4
mod  10  for  every  positive
n,  we  have:
lnzd(x
x
)   =   (x
)
4
mod  10
=   (lnzd  x)
4
mod  10.
This  completes  the  proof.
With  Lemma  3  at  our  disposal,  the  proof  of  Theorem  2  is  now  fairly  easy.
Proof  of  Theorem  2:   Again,  we  argue  by  contradiction.   Suppose  P  is  rational.   Let
0
  be  the  period,   and  choose  j  suciently  large  such  that  10
j
>  100(
0
 + 1)!   and
such  that  lnzd((10
j
+ n
0
)
10
j
+n
0
)  =  lnzd((10
j
)
10
j
)  for  every  positive  n.   Choosing
n = 100(
0
 + 1)(
0
  1)!,  we  get:
lnzd((10
j
+ 100(
0
 + 1)!)
10
j
+100(
0
+1)!
) = lnzd((10
j
)
10
j
).
We  reduce  the  left   side  of   the  above  equation  by  Lemma  3  and  the  right   side  is
obviously  1,  so  we  have:
(lnzd(10
j
+ 100(
0
 + 1)!))
4
mod  10 = 1,
but since 10
j
> 100(
0
+1)! and lnzd(100(
0
+1)!) = lnzd((
0
+1)!), we can rewrite
the  above  equation  as:
(lnzd  (
0
 + 1)!)
4
mod  10 = 1.
Note  that   by  Lemma  1,   the  only  values  of   lnzd((
0
  + 1)!)   are  2, 4, 6,   and  8,   and
raising  these  to  the  fourth  power  mod  10  gives  us:
6 = 1,
which  is  a  contradiction.   Thus,  P  is  irrational.   This  completes  the  proof.
We   close   by  asking  the   obvious   (and  very  dicult)   question:   Are   F   and  P
algebraic  or  transcendental?  I  suspect  the  latter,  but  it  is  only  a  hunch,  and  I  hope
some  curious  reader  will  continue  along  this  interesting  line  of  study.
References
[1]   R.   Euler  and  J.   Sadek,   A  number  that  gives  the  unit  digit  of   n
n
,   Journal   of
Recreational   Mathematics,  29  (1998)  No.  3,  pp.  2034.