Could Anybody tell me VBScript for
Check if a given number is Prime number-Don't use any Built-
in Functions Boolean/int is Prime(int number).. Thanks in
advance.
Answers were Sorted based on User's Feedback
Answer / pankaj
Function IsPrime(Num)
Dim varNum, varCtr, varLimit
varLimit = Round(Num/2)
For varCtr = 2 To varLimit
varNum = Num Mod varCtr
If varNum = 0 Then
IsPrime = False
Exit For
End If
Next
If varCtr >= varLimit Then
IsPrime = True
End If
End Function
MsgBox IsPrime(19)
| Is This Answer Correct ? | 1 Yes | 3 No |
Answer / sayali
Dim prime, n
prime = TRUE
n=cint(inputbox("Enter a number to find whether it is Prime or Not"))
for i=2 to (n-1)
If n mod i = 0 then
prime = False
Exit for
End if
Next
If prime then
msgbox "Yes! It is a Prime number"
Else
msgbox "No! it is not a prime number"
End if
| Is This Answer Correct ? | 0 Yes | 2 No |
Hi, Anybody could tell me What is the 3rd Largest Number in the series..Thanks in Advance..
explain with example primitive data types of vb script.
How to remove the spaces in a string Ex: "Welcome to QTPWorld" ?
Hello Guys, If any body looking for "worksoft certify tool training in bangalore", please contact me aimansaud@gmail.com
How are values assigned to the variables in the vbscript language?
Explain about operator precedence in vb script?
Inorder to avoid Message box while writing script which alternative method can be used?
how to write code: to check whether the window of an Application Under Test exist or not . plz give with example
What is the difference between function and procedure?
Explain the functionality of vbscript?
Write a code to print numbers from 5 to 0?
about vb scripting programs this type of all question& answers