Vb script program to find out given number is prime numbers or not? - TestingQ.com

-->Exclusive Portal for Testing Jobs

Vb script program to find out given number is prime numbers or not?

n=cint(inputbox("Enter a Number"))
IsPrime n
Function IsPrime(n)
flag=1
i=2
while i < n/2 and flag
if (n mod i =0) then
flag = 0
end if
i=i+1
wend
if flag =1 then
msgbox n&" is Prime"
else
msgbox n&" is Not Prime"
end if
End Function

Note: write the above code in notepad and save it as Isprime.vbs, then click on the file to enter a number, It will display whether the given number is prime or not. 

To receive daily posted JOBS & Interview Questions
Just enter your email address below and click 'Submit'
Enter your email address:

Make sure to activate your subscription by clicking on the activation link sent to your email