Prime Number Checker
Function to check whether a number is prime
(See Below Code)
|
'Call the Prime Function, with the number to check as
the parameter 'set c to begin checking the number with 2 1 'Set Errortrap to protect against invalid numbers - e.g.
strings 'Divide number by c to see if it will divide fully 'Add one to c to check number with a new value next time 'If c is over halfway of a then there will be no more
combinations 'Check to see if Checking has finished 'If an error occurs, the program goes to Invalid 'done 'An example of how the function could be called: |
(Copy and Paste this code into your Visual Basic project)
*Want to join the C0D3 MA5T3R e-mail list?*
Get all the latest code news and articles, and even submit your own.
You can sign-up for free below (you may opt-out at any time):