수행평가 1차:
다음 입·출력 예시를 참고하여 입력창에 자연수를 입력받은 후, 입력받은 수까지 소수의 합계를 구하세요.


코드 입력 하기 편집

Private Sub Command1_Click()

Dim i As Integer, j As Integer 

Dim prime As Boolean
Dim sum As Integer

sum = 0

For i = 2 To 5
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 '소수라면
sum = sum + i '더한다
Label3.Caption = sum
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