수행평가 1차:
다음 입·출력 설계을 참고하여 입력한 수까지의 소수의 개수를 구하는 프로그램을 만들어보세요.


코드 입력 하기 편집

Private Sub Form_Activate()
Dim i As Integer, j As Integer
Dim Prime As Boolean
for i= 2 to val(text1.text)
For I = 2 TO 50
Prime = True
For j=2 to i-1
If i mod j = 0 Then
Prime =false
Exit for
End If

Next j
If Prime Then
Print I
End if
Next i
End Sub


Private Sub Command1_Click()
Dim i As Integer, j As Integer
Dim prime As Boolean
Dim count As Integer
count = 0

For i = 2 To Val(Text1.Text)
prime = True
For j = 2 To i - 1
If i Mod j = 0 Then
prime = False
Exit For
End If

Next j
If prime Then
count = count + 1
Label1.Caption = "소수의 개수는 " & count & "개 입니다"

End If
Next i

End Sub

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on FANDOM

Random Wiki