Determine the total number of values of a 8-digit positive integer N such that the product of the digits of N is 2016.
Factoring 2016 into primes produces one set of digits
22222337
These can be permuted of course, and also multiplied together by digit, with the resulting set padded out with 1's:
11114789
11116678
11122789
11123678
11124479
11124667
11133478
11134467
11222479
11222667
11223378
11223467
11233447
12222279
12222367
12223347
22222337
from this Mintoris Basic program (Android):
global n, cell(), numcells, highdig,tot
dim cell(20)
''input "n:",n0
'Input "number of cells:",numcells
'input "size of grid:",highdig
n0=2016
numcells=8
highdig=9
open 2,"8 dig prod.txt","w"
'writeln 2, str$(n0 ), str$(numcells ), str$(highdig )
n = n0
addon(1)
close 2
End
Sub addon(wh)
If wh = 1 Then
st = 1
Else
st = cell(wh - 1)
endif
For factr = st To highdig
If n % factr = 0 Then
n = n / factr
tot=tot+factr
cell(wh) = factr
If wh = numcells Then
If n = 1 Then
For i = 1 To wh
write 2, str$(cell(i))
Next
writeln 2, " "
EndIf
Else
addon(wh + 1)
EndIf
n = n * factr
tot=tot-factr
Endif
Next
End Sub
Now annotating for permutations
11114789 8!/4! 1680
11116678 8!/(4!*2!) 840
11122789 8!/(3!*2!) 3360
11123678 8!/3! 6720
11124479 8!/(3!*2!) 3360
11124667 8!/(3!*2!) 3360
11133478 8!/(3!*2!) 3360
11134467 8!/(3!*2!) 3360
11222479 8!/(3!*2!) 3360
11222667 8!/(3!*2!*2!) 1680
11223378 8!/(2!*2!*2!) 5040
11223467 8!/(2!*2!) 10080
11233447 8!/(2!*2!*2!) 5040
12222279 8!/5! 336
12222367 8!/4! 1680
12223347 8!/(3!*2!) 3360
22222337 8!/(5!*2!) 168
--------
56784
So the answer is 56,784.
|
Posted by Charlie
on 2016-04-20 13:46:12 |