Sub 素数判定() Dim num As Integer num = Range("A1").Value For i = 2 To (num - 1) If num Mod i = 0 Then Range("A1").Value = num & "は素数ではない" Exit For Else Range("A1").Value = num & "は素数" End If Next i End Sub