The document is code that checks if a user-input number is prime. It uses a for loop to check if the number is evenly divisible by any number from 2 to half the input number. If a match is found, it outputs that the number is not prime, otherwise it is prime.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
16 views1 page
Prime Number Checker Script
The document is code that checks if a user-input number is prime. It uses a for loop to check if the number is evenly divisible by any number from 2 to half the input number. If a match is found, it outputs that the number is not prime, otherwise it is prime.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
userInput = Inputbox ("Enter any number")
for i = 2 to userInput/2 If userInput Mod i = 0 Then flag = 1 Exit for End If i=i+1 Next If flag = 1 Then Msgbox userInput & " is not a Prime number" Else Msgbox userInput & " is a Prime number" End If