Determine the total number of values of a 6-digit positive integer N such that the sum of the digits of N is equal to the product of the digits of N.
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
For a = 1 To 9
For b = a To 9
For c = b To 9
For d = c To 9
For e = d To 9
For f = e To 9
If a + b + c + d + e + f = a * b * c * d * e * f Then
Text1.Text = Text1.Text & a & b & c & d & e & f & " " & a + b + c + d + e + f & crlf
End If
Next
Next
Next
Next
Next
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
finds that only the digit set 111126 works.
There are 6 places the 2 could be and then 5 places the 6 could be, so there are a total of 6*5 = 30 such integers.
|
Posted by Charlie
on 2015-10-06 20:28:06 |