a.What two-digit number equals the product of units' digit by the factorial of tens' digit?
b. What if a non-decimal system (base below ten) were allowed?
In base 10 it's 36; in base 5 it's 33.
The output:
36
base 2
base 3
base 4
base 5
33
base 6
base 7
base 8
base 9
from
DefDbl A-Z
Dim crlf$, fact(9)
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr(13) + Chr(10)
fact(0) = 1
For i = 1 To 9
fact(i) = i * fact(i - 1)
Next
For tens = 1 To 9
If fact(tens) - 1 <> 0 Then
units = 10 * tens / (fact(tens) - 1)
If units = Int(units) And units >= 0 And units < 10 Then
Text1.Text = Text1.Text & tens & units & crlf
End If
End If
Next
For base = 2 To 9
Text1.Text = Text1.Text & crlf & "base " & base & crlf
For tens = 1 To base - 1
If fact(tens) - 1 <> 0 Then
units = base * tens / (fact(tens) - 1)
If units = Int(units) And units >= 0 And units < base Then
Text1.Text = Text1.Text & tens & units & crlf
End If
End If
Next
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
|
Posted by Charlie
on 2018-05-31 14:31:30 |