'---------------------------------------------------------- '素数を出力をする Sub exercise1() Dim i, n As Integer Dim count As Integer n = InputBox("nを入力") count = 0 For i = [ 1 ] If [ 2 ] Then count = count + 1 End If Next i If [ 3 ] Then MsgBox n & " は素数である" Else MsgBox n & " は素数でない" End If End Sub '---------------------------------------------------------- '素数と個数を出力する Sub exercise2() Dim i, j, n As Integer Dim count, sum As Integer n = InputBox("nを入力") sum = 0 For j = 2 To n count = 0 For i = [ 1 ] If [ 2 ] Then count = count + 1 End If Next i If [ 3 ] Then MsgBox j & " は素数である" sum = [ 4 ] End If Next j MsgBox "素数の個数=" & sum End Sub '---------------------------------------------------------- '1から数えてn番目の素数を出力 Sub exercise3() Dim i, j, n As Integer Dim countU, countD As Integer n = InputBox("nを入力") countD = n j = 0 Do j = j + 1 countU = 0 For i = [ 1 ] If [ 2 ] Then countU = countU + 1 End If Next i If [ 3 ] Then countD = countD - 1 End If Loop While [ 4 ] MsgBox n & " 番目の素数=" & j End Sub