Dim yes As Boolean Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 realans = 1 Input #1, num ans = num & "=" For i = 2 To num For ii = 1 To i If i Mod ii = 0 Then mycount = mycount + 1 Next If mycount = 2 Then yes = True If num Mod i = 0 And yes = True Then ans = ans & i & "*": realans = realans * i mycount = 0: yes = False If realans = num Then Exit For Next Print #2, Left(ans, Len(ans) - 1) Close #2 Close #1 End End Sub
Dim msg As String Dim tof As Boolean Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do While Not EOF(1) Input #1, x msg = x & " = ": cof = True Call a(Val(x)) Loop Close #2 Close #1 End End Sub
Sub a(b) If b = 1 Then Print #2, Left(msg, Len(msg) - 2): End For i = 2 To b tof = True For j = 2 To i - 1 If i <> j Then If i Mod j = 0 Then tof = False End If Next j If tof = True And b Mod i = 0 Then b = b / i: msg = msg & i & " * ": Call a(b) Next i End Sub
Dim yes As Boolean
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
realans = 1
Input #1, num
ans = num & "="
For i = 2 To num
For ii = 1 To i
If i Mod ii = 0 Then mycount = mycount + 1
Next
If mycount = 2 Then yes = True
If num Mod i = 0 And yes = True Then ans = ans & i & "*": realans = realans * i
mycount = 0: yes = False
If realans = num Then Exit For
Next
Print #2, Left(ans, Len(ans) - 1)
Close #2
Close #1
End
End Sub
Dim msg As String
回覆刪除Dim tof As Boolean
Private Sub Form_Load()
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do While Not EOF(1)
Input #1, x
msg = x & " = ": cof = True
Call a(Val(x))
Loop
Close #2
Close #1
End
End Sub
Sub a(b)
If b = 1 Then Print #2, Left(msg, Len(msg) - 2): End
For i = 2 To b
tof = True
For j = 2 To i - 1
If i <> j Then
If i Mod j = 0 Then tof = False
End If
Next j
If tof = True And b Mod i = 0 Then b = b / i: msg = msg & i & " * ": Call a(b)
Next i
End Sub