Monday, April 26, 2010

Print prime numbers

This logic finds all the prime numbers upto the number specified.

flag=1
primeNo=inputbox("Enter a number")
For i=2 to primeNo
flag=1
For j=2 to i/2
If i mod j=0 Then
flag=0
End If
Next

If flag=1 Then
msgbox i
End If
Next

1 comment:

Unknown said...

what is the use of Flag