## A $3$-smooth number is an integer which has no prime factor larger than $3$. For an integer $N$, we define $S(N)$ as the set of $3$-smooth numbers less than or equal to $N$. For example, $S(20) = \{ 1, 2, 3, 4, 6, 8, 9, 12, 16, 18 \}$.

We define $F(N)$ as the number of permutations of $S(N)$ in which each element comes after all of its proper divisors.

This is one of the possible permutations for $N = 20$.

– $1, 2, 4, 3, 9, 8, 16, 6, 18, 12.$

This is not a valid permutation because $12$ comes before its divisor $6$.

– $1, 2, 4, 3, 9, 8, \boldsymbol{12}, 16, \boldsymbol 6, 18$.

We can verify that $F(6) = 5$, $F(8) = 9$, $F(20) = 450$ and $F(1000) \approx 8.8521816557\mathrm e21$.

Find $F(10^{18})$. Give as your answer its scientific notation rounded to ten digits after the decimal point.

When giving your answer, use a lowercase e to separate mantissa and exponent. E.g. if the answer is $112\,233\,445\,566\,778\,899$ then the answer format would be 1.1223344557e17.

### This problem involves the concept of dynamic programming and inclusion-exclusion principle.

All the $3$-smooth numbers can be represented as $2^i \cdot 3^j$, where $i$ and $j$ are natural numbers including zero. So, every $3$-smooth integer can be mapped onto the $2D$ grid $(i, j)$, where $i, j \geq 0$.

In other words, each grid point $(i,j)$ represents all $3$-smooth numbers of the form $2^i \cdot 3^j$.

If we have a permutation of these numbers of length $n$, we create the permutation in such a way that every number should be placed after all of its proper divisors. Therefore, if a number is represented by a point $(i, j)$, all its proper divisors are at a point $(i’, j’)$, such that either $i’ < i$ or $j' < j$ but not both at the same time. So, for a valid permutation, a point can only be visited after all points below it and to the left of it have been visited. This forms a grid path where we can only move upwards or towards the right. For any point $(i, j)$, there are $(i+j)$ ways to reach it if we move only upwards or towards the right. So, each point on the grid, has the binomial coefficient ${i+j}\choose{i}$ paths to reach it. And by the multiplication principle, total permutations are the product of each individual path count. We also need to understand that the total permutations will over count the number of valid sequences as it also includes sequences where both $i$ and $j$ are incremented at the same time which violates our condition. With these observations, we can apply concepts of dynamic programming to compute $F(10^{18})$. To avoid over counting, we use the inclusion-exclusion principle where we sum up the solutions for paths that only turn right or upwards and subtract the solutions where both $i$ and $j$ increment simultaneously. If we implement these steps and compute $F(10^{18})$, we'll get approximately $1.6035141912e832309896$. So, the answer is 1.6035141912e832309896. This problem involves a lot of math, programming and problem-solving knowledge, revealing the beauty and complexity of Mathematic research.

##### More Answers:

Flipping GameAn Ant on the Move

Almost Pi