We define a number's persistence as the number of steps required to reduce it to a single digit by multiplying all its digits together repeatedly. For example, 77 has a persistence of four because it requires four steps to reduce it to one digit:
7 7 → 4 9 → 3 6 → 1 8 → 8
What is the smallest number of persistence nine?
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.
first attempt : use a while loop that will stop when it finds a solution (f(n) == 9) -> takes a long time using python
second attempt : use a while loop that will stop when it finds a number from which I can build the solution (f(n) == 8) the least n | f(n) == 8 is 4478976 which has a prime factorization 2 1 1 × 3 7 now I want a number whose digits has a product equal to that number ... by grouping each 3 2s group in a single 8 and each 2 3s group into a single 9 -> 2^2 * 3 * 888*999 ... the best way to group 2 2 3 is as 26 -> ans = 26888999
How can one prove there is no n<23888999 has a persistence equal to 9?(when using your method).
By factoring and grouping ( 2 , 1 0 = 2 × 5 ) , ( 3 , 2 5 = 5 × 5 ) , ( 4 , 5 5 ? ) .
Log in to reply
just to be clear I don't know whether you mean
1) how to prove that the least n with digit product = 4478976 is 26888999 ?
or
2) how to prove that there is no n < 26888999 with digit product m > 4478976 and the persistence of m = 8 which is legit -more below- ?
so I'll prove both
1) how to prove that the least n with digit product = 4478976 is 23888999 ? this can be done in several ways but the one I thought of is using dynamic programming as it has an optimal sub-structure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
2) how to prove that there is no n < 26888999 with digit product m > 4478976 and the persistence of m = 8 which is legit ?
to do that is simple 4478976 < n < 26888999 which implies that n contains at least 7 digits and at most 8 digits with digit product 5 3 1 4 4 1 0 = 2 × 5 × 9 6 corresponding to 25999999 , any other number < 26888999 has a digit product ≤ 5 3 1 4 4 1 0 ... 5 3 1 4 4 1 0 is not that big and we can verify that there is no number ≤ 5 3 1 4 4 1 0 with persistence = 8 and its prime factorization contains only one digit primes {2,3,5,7} -legit number- other than 4478976 and no number has persistence = 9 in that range using brute force
and as 4478976 is the only legit number < 5 3 1 4 4 1 0 with persistence = 8 it follows that the smallest number with digit product 4478976 is the answer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Log in to reply
Meant the second question, thanks for the clear explanation.
Problem Loading...
Note Loading...
Set Loading...