All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Factorial zeros (Posted on 2011-02-17)
41! = 33452526613163807108170062053440751665152000000000
which is 50 digits long, the last 9 of them are 0s. Thus the trailing zeros make up 18% of the entire number.

Find n where n! has the largest possible proportion of trailing 0s.

Prove it.

 No Solution Yet Submitted by Jer Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 Exploration and an attempt at proof. | Comment 2 of 4 |
` n         digits in     trailing           proportion               n!          zeros 5             3             1             .3333333333333333 6             3             1             .3333333333333333 7             4             1             .25 10            7             2             .2857142857142857 11            8             2             .25 `

The above five values of n are the only ones under 1000 (and presumably the only five altogether) that have a proportion of at least 1/4. Both 5! and 6! have a proportion of 1/3, which seems to be the largest.

DECLARE FUNCTION lxf# (x#)
DECLARE FUNCTION log10# (x#)
DEFDBL A-Z

DIM SHARED loge10, twopi

loge10 = LOG(10)
twopi = 8 * ATN(1)

CLS
FOR n = 1 TO 1000
alldigs = INT(lxf(n)) + 1
n2 = n
trailzeros = 0
WHILE n2 >= 5
q = n2 \ 5
trailzeros = trailzeros + q
n2 = q
WEND
IF trailzeros / alldigs >= .25 THEN
PRINT n, alldigs, trailzeros, trailzeros / alldigs
END IF
NEXT n

FUNCTION log10 (x)
log10 = LOG(x) / loge10
END FUNCTION

FUNCTION lxf# (x#)
IF x# < 171 THEN
fact# = 1
IF x# > 1 THEN
FOR i = 2 TO x#
fact# = fact# * i
NEXT
END IF
lo# = log10#(fact#)
ELSE
lo# = log10#(x#) * (x# + .5#)
lo# = lo# + (-x# + 1# / (12# * x#) - 1# / (360# * x# * x# * x#) + 1# / (1260# * x# * x# * x# * x# * x#)) / loge10#
lo# = lo# + log10#(twopi#) / 2#
END IF
lxf# = lo#
END FUNCTION

While the proportion is not monotonically decreasing, it is the general trend:

` n         digits in     trailing           proportion               n!          zeros3             1             0             04             2             0             05             3             1             .33333333333333336             3             1             .33333333333333337             4             1             .258             5             1             .29             6             1             .166666666666666710            7             2             .285714285714285711            8             2             .2512            9             2             .222222222222222213            10            2             .214            11            2             .181818181818181815            13            3             .230769230769230816            14            3             .214285714285714317            15            3             .218            16            3             .187519            18            3             .166666666666666720            19            4             .210526315789473721            20            4             .222            22            4             .181818181818181823            23            4             .173913043478260924            24            4             .166666666666666725            26            6             .230769230769230826            27            6             .222222222222222227            29            6             .206896551724137928            30            6             .229            31            6             .193548387096774230            33            7             .212121212121212131            34            7             .205882352941176532            36            7             .194444444444444433            37            7             .189189189189189234            39            7             .179487179487179535            41            8             .195121951219512236            42            8             .190476190476190537            44            8             .181818181818181838            45            8             .177777777777777839            47            8             .170212765957446840            48            9             .187541            50            9             .1842            52            9             .173076923076923143            53            9             .16981132075471744            55            9             .163636363636363645            57            10            .175438596491228146            58            10            .172413793103448347            60            10            .166666666666666748            62            10            .161290322580645249            63            10            .158730158730158750            65            12            .1846153846153846`
`10            7             2            0.28571429100           158           24           0.151898731000          2568          249          0.0969626210000         35660         2499         0.07007852100000        456574        24999        0.054753451000000       5565709       249998       0.0449175510000000      65657060      2499999      0.03807662100000000     756570557     24999999     0.033043841000000000    8565705523    249999998    0.02918615`

When n is between 100 and 1000, each successive number adds at least 2 to the total number of digits. Only every fifth number adds 1 to the number of zeros; only every 25th adds a second zero as well, and every 125th a third.

In successive decades, or orders of magnitude, similar numbers apply, with the "at-least" increment going up by one in each successive order of magnitude, but the increments of zeros going up by less and less each time (logarithmically, as base-5 logarithms, since the successive additions come only 1/5 as often).

 Posted by Charlie on 2011-02-17 20:39:20

 Search: Search body:
Forums (0)