2009年4月8日 星期三

求 N 的所有質因數

image

'求 N 的所有質因數
Public Class Form1
    Dim i
    Dim str1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim n = 30
        For i = 1 To n
            If n Mod i = 0 Then
                Dim c = 0
                Dim j
                For j = 1 To i
                    If i Mod j = 0 Then
                        c = c + 1
                    End If
                Next
                If c = 2 Then
                    str1 = str1 & i & "  "
                End If
            End If
        Next
        MsgBox(str1)
    End Sub
End Class

沒有留言:

張貼留言