Base 12?

Find the smallest integer N N such that when N ! N! is written in base 12 , it has 121 trailing zeros . Enter your answer in base 6 .


The answer is 1052.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

John L
Aug 6, 2018

Disclaimer: I am relatively new in writing solutions, so I see myself as blind when it comes to telling the difference between pseudo-maths and maths-maths. If you happen to catch anything odd in this solution, please reply. If any of my "theories" are wrong, please reply as well so that everybody may benefit. :-)

Initial Thoughts of the Mind

12 12 can be prime factored into 2 2 × 3 2^2 \times 3 . Furthermore, N ! N! can be factored into 1 2 a × k 12^a \times k where a a is the number of trailing zeroes and 12 k 12 \nmid k . From 1 2 a = 4 a × 3 a = 2 2 a × 3 a 12^a = 4^a \times 3^a = 2^{2a} \times 3^a , it follows that we need to find min ( v 2 ( N ) 2 , v 3 ( N ) ) \min(\left\lfloor{\frac{v_2(N)}{2}}\right\rfloor, v_3(N)) where the function v p ( n ) v_p(n) is given as: v p ( n ) = i = 1 k n p i = n p + n p 2 + n p 3 + + n p k , \begin{aligned} v_p(n) &= \sum_{i=1}^k \left\lfloor{\frac{n}{p^i}}\right\rfloor \\ \\ &= \left\lfloor{\frac{n}{p}}\right\rfloor+\left\lfloor{\frac{n}{p^2}}\right\rfloor+\left\lfloor{\frac{n}{p^3}}\right\rfloor+\dots+\left\lfloor{\frac{n}{p^k}}\right\rfloor, \end{aligned} where k = log p n k=\left\lfloor \log_p{n} \right\rfloor .

Note that we floor v 2 ( N ) 2 \frac{v_2(N)}{2} to ignore any decimal points and remainders obtained from dividing by 2.

To simplify things, perhaps it might be possible to theorise which prime number (either 2 2 or 3 3 ) will be sparser throughout the product of the factorial N ! N! . When dealing with base 10 10 , we could theorise that 5 5 is sparser relative to 2 2 and as such, we only counted the highest power of 5 5 . With 2 2 and 3 3 however, it's rather difficult to tell. With base 10 10 , 2 2 < 5 2^2 < 5 , so we are reassured that the ratio of 2 2 's and 5 5 ’s will eventually reach or exceed 2 : 1. With base 12 12 , each 3 3 has to be compensated with two 2 2 's. However, we aren't guaranteed that the growth will be entirely linear and keep a 2 : 1 ratio between the number of 2 2 ’s and the number of 3 3 ’s because 3 < 2 2 3 < 2^2 . In this solution, I chose to count the number of 3's.

Developing a Fast Algorithm

Let's first obtain a rough estimate of our integer N N . We could do a linear search starting from 1 1 all the way up to our integer N N but that would take much too long to test (for some, at least).

Instead, we can make use of the geometric-series-sum formula: S = u 1 ( 1 r n ) 1 r , \begin{aligned} S = \frac{u_1 (1-r^n)}{1-r}, \end{aligned} where u 1 u_1 is the first term of the sequence, r r is the common ratio between consecutive terms, and n n is the number of terms in the geometric progression.

Now how can we apply this formula? Firstly, we can treat the summation of v p ( n ) v_p(n) as a sequence of integers a m m Z a_m \forall m \in Z . Treating this as a sequence, we can take a 0 = N a_0 = N then iterate through all a i = a i 1 p a_i = \left\lfloor \frac{a_{i-1}}{p} \right\rfloor where 1 i k , k = log p n 1 ≤ i ≤ k, k = \left\lfloor \log_p{n} \right\rfloor . Also from the theorem of v p ( n ) v_p(n) , we may observe each consecutive term experiencing a multiplicative factor of 1 p \frac{1}{p} . We will use this multiplicative factor as our common ratio, r r .

We shall remove the mapping of the floor function for the simplicity of the geometric-series summation. (Note that, by waiving the floor function, we are subjecting our sum to an accumulation of continuous values. And this is the cause for the inaccuracy of this part of the algorithm, regardless of the fact that it's quick to use).

We can obtain an estimate for v p ( n ) v_p(n) by using the geometric-series-sum formula stated above and ignoring the floor function. (Mind though, that this will often lead to an estimate of v p ( n ) v_p(n) , and not its exact value.) By doing this, we have a convenient way of pinpointing the whereabouts of N N .

We shall state this function as w p ( n ) w_p(n) : w p ( n ) = i = 1 k n p i = n ( 1 1 p k ) 1 1 p n , \begin{aligned} w_p(n) &= \sum_{i=1}^k \frac{n}{p^i} \\ \\ &= \frac{n (1 - \frac{1}{p^k})}{1-\frac{1}{p}} - n, \end{aligned} where k = log p n k=\left\lfloor \log_p{n} \right\rfloor .

To clarify the use of subtracting n n at the end, we need to acknowledge that n n itself is not supposedly part of our sum. We consider it the a 0 a_0 but our summation officially begins for a i a_i when i = 1 i = 1 .

Further simplification using algebra brings us to w p ( n ) = n ( p k 1 ) p k ( p 1 ) \begin{aligned} w_p(n) &= \frac{n (p^k - 1)}{p^k (p - 1)} \end{aligned}

To further simplify the equation, we could also treat the sequence from our previous theorems as an infinite geometric progression. By summing an infinite progression, smaller and smaller values will keep being added. As i i approaches zero, a i a_i approaches 0. The series converges due to our common ratio, r = 1 p r = \frac{1}{p} being in between 1 -1 and 1 1 (to be more precise, 0 < r < 1 0 < r < 1 as we will never be getting a negative prime, p p ).

The sum of an infinite geometric progression goes: S = u 1 1 r , \begin{aligned} S &= \frac{u_1}{1-r}, \end{aligned} where u 1 u_1 is the first term of the progression and r r is the common ratio.

Thus, we could restate w p ( n ) w_p(n) as w p ( n ) = i = 1 n p i = n 1 1 p n \begin{aligned} w_p(n) &= \sum_{i=1}^\infty \frac{n}{p^i} \\ \\ &= \frac{n}{1-\frac{1}{p}} - n \end{aligned} Further algebraic simplification leads us to w p ( n ) = n p 1 \begin{aligned} w_p(n) &= \frac{n}{p - 1} \end{aligned}

Keep in mind that our current w p ( n ) w_p(n) is not entirely the same function as our previous w p ( n ) w_p(n) . Further consequences involve a less accurate value returned and a higher deviation from the exact value.

This, however, provides a straight-forward function to use since it is easy to manipulate and isolate variables.

Solving the Problem: Finding N

w p ( n ) w_p(n) will only provide us an estimate. We might possibly need to do a linear search and check every number after applying the formula for w 3 ( n ) = 121 w_3(n) = 121 . w 3 ( n ) = n 3 1 121 = n 2 121 = n 2 n = 242 \begin{aligned} w_3(n) &= \frac{n}{3 - 1} \\ \\ 121 &= \frac{n}{2} \\ \\ 121 &= \frac{n}{2} \\ \\ n &= 242 \end{aligned}

Using this estimate of N N , we can test this value (and possibly consecutive values) using v p ( n ) v_p(n) . First we count the number of 2 2 's using v 2 ( 242 ) v_2(242) : v 2 ( 242 ) = 242 2 1 + 242 2 2 + + 242 2 7 = 237 \begin{aligned} v_2(242) &= \left\lfloor{\frac{242}{2^1}}\right\rfloor + \left\lfloor{\frac{242}{2^2}}\right\rfloor + \dots + \left\lfloor{\frac{242}{2^7}}\right\rfloor \\ \\ &= 237 \end{aligned} We stop at 2 7 2^7 since log 2 242 = 7 \left\lfloor{\log_2{242}}\right\rfloor = 7 .

We also need to count the number of 3 3 's using v 3 ( 242 ) v_3(242) : v 3 ( 242 ) = 242 3 1 + 242 3 2 + + 242 3 4 = 116 \begin{aligned} v_3(242) &= \left\lfloor{\frac{242}{3^1}}\right\rfloor + \left\lfloor{\frac{242}{3^2}}\right\rfloor + \dots + \left\lfloor{\frac{242}{3^4}}\right\rfloor \\ \\ &= 116 \end{aligned} Likewise, we stop at 3 4 3^4 as log 3 242 = 4 \left\lfloor{\log_3{242}}\right\rfloor = 4 .

Computing min ( v 2 ( N ) 2 , v 3 ( N ) ) \min(\left\lfloor{\frac{v_2(N)}{2}}\right\rfloor, v_3(N)) gives us 116 116 which is only 5 5 zeroes away from our goal. We shall now apply a linear search method and accumulate our zeroes starting from N = 243 N = 243 by first prime factorising N N .

243 = 3 5 243 = 3^5

We can add five 3 3 's to our already existing one-hundred-(and)-sixteen 3 3 's, giving us (currently) a grand total of 2 237 2^{237} and 3 121 3^{121} . Yay, we reached 121!!! Indeed, that may be a cause for celebration, but computing min ( v 2 ( N ) 2 , v 3 ( N ) ) \min(\left\lfloor{\frac{v_2(N)}{2}}\right\rfloor, v_3(N)) unfortunately gives us 118. This is due to v 2 ( N ) v_2(N) having a value of 237. Ah, so now we need to ensure that there will be at least 242 (or 243) 2 2 's and at least 121 3 3 's. Let's keep this in mind now (if you already had this in mind, good on you).

244 = 2 2 × 6 1 1 244 = 2^2 \times 61^1 Grand Total: 2 239 2^{239} , 3 121 3^{121}

245 = 5 1 × 7 2 245 = 5^1 \times 7^2 Grand Total: 2 239 2^{239} , 3 121 3^{121}

246 = 2 1 × 3 1 × 4 1 1 246 = 2^1 \times 3^1 \times 41^1 Grand Total: 2 240 2^{240} , 3 122 3^{122}

We have exceeded 121 3 3 's, so now we are hoping that there will be 2 or 3 more 2 2 's in store for us.

247 247 ... skip this, no factors of 2 or 3 here.

248 = 2 3 × 31 248 = 2^3 \times 31 Grand Total: 2 243 2^{243} , 3 122 3^{122} .

We have reached a point where we have 243 2 2 's and 122 3 3 's. Going any further with higher values of N N will only give us more factors of 2 and 3 to worry about. 248 is our smallest integer N N such that when N ! N! is written in base 12 , it has 121 trailing zeroes (restating statement from question). 249 is also a possible candidate since min ( v 2 ( N ) 2 , v 3 ( N ) ) \min(\left\lfloor{\frac{v_2(N)}{2}}\right\rfloor, v_3(N)) also equals 121 121 . However, we shall hang on tight to 248 since it is our smallest candidate.

Solving the Problem: Converting to Base 6

A method of converting any number, M 10 M_{10} from base 10 10 to base x x is to find the highest power i i of x x such that x i M 10 x^i ≤ M_{10} . A way to start off is to draw a 'T' table listing pairs of i i and x i x^i . The table for x = 6 x = 6 is listed below for values of i i up to i = log 6 248 = 3 i = \left\lfloor{\log_6{248}}\right\rfloor = 3 .

i i x i x^i
0 0 1 1
1 1 6 6
2 2 36 36

|| 3 3 || 216 216 ||

Now we shall iterate through values of x i x^i starting from the largest value (i.e. 216 216 ). As we iterate, we shall write a i a_i in the form a i = b i × 6 i + a i 1 a_i = b_i \times 6^i + a_{i-1} (as in a = b × q + r a = b \times q + r ) so that a i 1 < 6 i a_{i-1} < 6^i . We shall then note down the value of b i b_i then repeat for a i 1 a_{i-1} . Our numeric conversion terminates once i = 0 i = 0 . (There is probably a neat algorithmic approach to notate this paragraph, but I couldn't get it right.) Keep in mind that a m a x ( i ) = M 10 a_{max(i)} = M_{10} . In our current case, a 3 = 248 a_3 = 248 .

248 = 1 × 6 3 + 32 32 = 0 × 6 2 + 32 32 = 5 × 6 1 + 2 2 = 2 × 6 0 + 0 \begin{aligned} 248 &= 1 \times 6^3 + 32 \\ \\ 32 &= 0 \times 6^2 + 32 \\ \\ 32 &= 5 \times 6^1 + 2 \\ \\ 2 &= 2 \times 6^0 + 0 \\ \\ \end{aligned}

We may conclude that 24 8 10 = 105 2 6 248_{10} = 1052_{6} and 105 2 6 1052_6 is the smallest integer in base 6 that when 105 2 6 ! 1052_6! is written in base 12, it has 121 trailing zeroes \square .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...