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 |
Explain about scrrun.dll in vbscript?
can u test the application without add-in?
what is fire event method in qtp?
Can any 1 modify the code whr in want to add\rename a excel sheet in qtp?
How to write a VBscript for web page performance test i need a code send if any knows the code If any knows VBScript book plz send to me the link to my mail plz
write a vb script to display factorial of a number using function
How to Enter Values on the Command promt using VB script
can anyone tell me the procedure of interview held in applabs
Explain different types of segment?
How can you create a file object to work with the files in the vbscript language?
write a qtp script to count the number of minimized windows
How can you destroy an object in vbscript?