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

Home > Just Math
Factorial sequence (Posted on 2006-03-02) Difficulty: 3 of 5
Factorials exhibit an interesting trait. The minimum value needed for the length of x! to reach nx, where n is a positive integer, forms an interesting sequence. Let len(x!) = int(log(x!))+1 to account for the extra digit.

What is the relationship between len(x!) and x?

What is the smallest number such that the len(x!)>=8x?

How can I approximate when len(x!) first exceeds/equals nx?

See The Solution Submitted by Justin    
Rating: 4.0000 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer exploration | Comment 1 of 2

As a good approximation to the log(x!) --common log-- I use

 log(x) * (x + .5) +  (-x + 1/(12*x) - 1/(360*x^3) + 1/(1260*x^5)) / ln(10) + log(2*pi)/2
 
based on a formula for the Gamma function of x (as x! = Gamma(x+1)), found in the 11th edition Encyclopaedia Britannica:

Gamma(x) = ((x^x) / sqrt(x)) * e^-x * sqrt(2*pi) * e^(B1/(1*2*x) - B2/(3*4*x^3) + B3/(5*6*x^5) - ... )

where the B#'s are Bernoulli numbers: B1 = 1/6, B2 = 1/30, B3 = 1/42, ...

I used the following program to increase x geometrically until the desired length (1 more than the integer part, or characteristic, of the common log of the factorial) was exceeded, then decrease until it was not reached, by factors closer and closer to 1 until a number is settled on.  Then lengths were evaluated from 20 before to 20 after the converged value.

DECLARE FUNCTION log10# (x#)
DECLARE FUNCTION lxf# (x#)
CONST pi# = 3.14159265358979# + 3.24D-15
CONST twopi# = 2# * pi#
CONST e# = 2.71828182845904# + 5.24D-15
CONST loge10# = 2.30258509299404# + 5.68D-15
CONST einv# = 1# / e#
CONST radDeg# = 180# / pi#

CLS


DEFDBL A-Z

CLS

FOR i = 1 TO 40: PRINT i, INT(lxf#(i)) + 1: NEXT
PRINT
f = 1.1

DO
  DO
   i = INT(i * f)
   l = INT(lxf#(i) + 1)
   a$ = INKEY$
  LOOP UNTIL l >= 8 * i OR a$ = CHR$(27)
  IF a$ = CHR$(27) THEN EXIT DO
  PRINT i, l, l / i
  f = 1 - (f - 1) / 2
  DO
   i = INT(i * f)
   l = INT(lxf#(i) + 1)
   a$ = INKEY$
  LOOP UNTIL l < 8 * i OR a$ = CHR$(27)
  IF a$ = CHR$(27) THEN EXIT DO
  f = 1 + ABS(f - 1) / 2
  PRINT i, l, l / i
LOOP UNTIL INKEY$ = CHR$(27) OR a$ = CHR$(27)

j = i
FOR i = j - 20 TO j + 20
   l = INT(lxf#(i) + 1)
   PRINT i, l, l / i
NEXT

DEFINT A-Z


END

DEFDBL A-Z
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

The convergence went:

    x           len(x!)        len(x!) / x
 294108723     2362932255    8.034213439497339
 265433115     2120720512    7.989660642003919
 272068944     2176656165    8.000384509155886
 268668081     2147980247    7.994921611101246
 272036926     2176386104    8.000333395915524
 271186810     2169216269    7.99897409833465
 272034930     2176369268    8.000330207595033
 271822402     2174576711    7.999990784424015
 271928582     2175472272    8.000160395055493
 271822369     2174576432    7.9999907292398
 271848914     2174800321    8.000033139731432
 271822366     2174576407    7.999990725560824
 271829002     2174632377    8.000001328040781
 271825683     2174604383    7.999996023186669
 271829001     2174632368    8.000001324362001
 271827341     2174618368    7.99999867562991
 271828583     2174628843    8.000000658503231
 271828167     2174625334    7.999999992642411
 271828270     2174626203    8.00000015818811
 271828166     2174625326    7.999999992642411
 271828191     2174625537    8.000000033109149
 271828165     2174625317    7.999999988963616
 271828171     2174625368    8
 271828167     2174625334    7.999999992642411
 271828170     2174625360    8
 271828169     2174625351    7.999999996321206


 
 indicating 271828170 is the first where the quotient is exactly 8.  The span of values shows:


 
 271828149     2174625182    7.999999963212051
 271828150     2174625191    7.999999966890846
 271828151     2174625199    7.999999966890846
 271828152     2174625208    7.999999970569641
 271828153     2174625216    7.999999970569641
 271828154     2174625225    7.999999974248436
 271828155     2174625233    7.999999974248436
 271828156     2174625241    7.999999974248436
 271828157     2174625250    7.999999977927231
 271828158     2174625258    7.999999977927231
 271828159     2174625267    7.999999981606027
 271828160     2174625275    7.999999981606027
 271828161     2174625284    7.999999985284822
 271828162     2174625292    7.999999985284822
 271828163     2174625300    7.999999985284822
 271828164     2174625309    7.999999988963616
 271828165     2174625317    7.999999988963616
 271828166     2174625326    7.999999992642411
 271828167     2174625334    7.999999992642411
 271828168     2174625343    7.999999996321205
 271828169     2174625351    7.999999996321206
 271828170     2174625360    8
 271828171     2174625368    8
 271828172     2174625376    8
 271828173     2174625385    8.000000003678794
 271828174     2174625393    8.000000003678794
 271828175     2174625402    8.000000007357588
 271828176     2174625410    8.000000007357588
 271828177     2174625419    8.000000011036384
 271828178     2174625427    8.000000011036384
 271828179     2174625435    8.000000011036384
 271828180     2174625444    8.000000014715178
 271828181     2174625452    8.000000014715178
 271828182     2174625461    8.000000018393973
 271828183     2174625469    8.000000018393973
 271828184     2174625478    8.000000022072767
 271828185     2174625486    8.000000022072767
 271828186     2174625494    8.000000022072767
 271828187     2174625503    8.000000025751561
 271828188     2174625511    8.000000025751561
 271828189     2174625520    8.000000029430355
  

where three values show exactly 8 and then increasing values.
 
 The interesting thing about 271828170, is its closely following the digits of e.  It is 12 or 13 short of mimicking or approximating the first 8 digits (or rounded digits) of e.
 
 The values of x, len(x!) and len(x!) / x where the length is an integral multiple of the base number, up to 10 are shown (except for len(1!)/1 = 1):


 
 22            22            1
 23            23            1
 24            24            1
 266           532           2
 267           534           2
 268           536           2
 2712          8136          3
 2713          8139          3
 27175         108700        4
 27176         108704        4
 271819        1359095       5
 271820        1359100       5
 271821        1359105       5
 2718272       16309632      6
 2718273       16309638      6
 27182807      190279649     7
 27182808      190279656     7
 271828170     2174625360    8
 271828171     2174625368    8
 271828172     2174625376    8
 2718281815    24464536335   9
 2718281816    24464536344   9
 27182818270   271828182700  10
 27182818271   271828182710  10


 
 BTW 27182818270! is about 1.9 x 10^271828182699 and 27182818271! is about 5.2 x 10^271828182709.


  Posted by Charlie on 2006-03-02 11:19:50
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (4)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information