Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27388

Designing a program to check whether n is prime or not

$
0
0
Hey, i'm trying to create a working algorithm to check a number (n) input into the system. The problem i'm facing is the break and continue function which i need to work to get my flag up and running so i can code this into vb. Here's what i have so far.

BEGIN PrimeChecker
Get number
Let x = number/2
Let Flag = True
For i = 2 to x
i = i + 1
IF number mod i = 0
Flag = False
Break
ELSE
Continue
ENDIF
Next i
IF Flag = True
Display "Number is a prime"
ELSE
Display "Number is not a prime"
ENDIF
END PrimeChecker

Viewing all articles
Browse latest Browse all 27388

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>