Imports System.IO
Imports System.Text
Module Module1
Sub Main()
Dim sw As StreamWriter = New StreamWriter("C:\Users\hasho\Desktop\艾草_out.txt", False, Encoding.Default)
Dim sr As StreamReader = New StreamReader("C:\Users\hasho\Desktop\艾草_in.txt", Encoding.Default)
Dim I As Integer, J As Integer, put1 As Integer, idx As Integer, put(50) As Integer, k As Integer, sd As Integer, put5 As Integer, wsd As Integer
Dim num(1000) As Integer '質數
For I = 2 To 1000
num(I) = I
Next
For I = 2 To 1000
If num(I) <> 0 Then
For J = 2 To 1000 \ I
num(J * I) = 0
Next
End If
Next
Dim num2(idx) As Integer '質因數
put1 = Convert.ToInt32(sr.ReadLine)
put5 = put1
For wsd = 1 To put5
ReDim num2(idx)
idx = Convert.ToInt32(sr.ReadLine)
sw.Write("{0}=", idx)
If idx = 1 Then
sw.Write("1")
End If
For ws = 1 To put1
For I = 2 To idx
If num(I) <> 0 Then
LO: '回到這
If idx Mod I = 0 Then
idx = idx / I
sw.Write("{0}", I)
If idx + 1 > I Then
sw.Write("*")
End If
End If
If idx Mod I = 0 Then
GoTo LO ' 從這
End If
End If
Next
Next
sw.WriteLine()
Next
sw.Close()
sr.Close()
End Sub
End Module