Write a VB program to fin the sum of the first 10 prime numbers,using the FOR...Next loop.
Answers
Answered by
8
Answer:
A number that is divisible only by itself and 1. Example: (2, 3, 5, 7, 11, 13, 17). One is not a prime number according to the definition a Prime number is divisible with 1 and itself and one doesn’t have exactly two positive divisors.
Explanation:
Private Sub cmdPrime_Click()
Dim p, n, i As Integer
p = 1
Print “Prime Numbers are : “
For n = 1 To 100
For i = 2 To n – 1
If n Mod i = 0 Then
p = 0
Exit For
Else
p = 1
End If
Next
If p = 1 Then
Print n
End If
Next
End Sub
Similar questions