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.
Answer Posted / 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 |
Post New Answer View All Answers
What's the difference between vbscript and vb.net?
How will you reverse a string in vbscript?
Write a test case using Test if the images,a particular test exists,check if the page links match,page response is within a certain range,parameterization of the test,the test should comprise of actions,the test should use a custom function,the test should use global repository
how to write codings in QTP using vb script. please help me. i am new to QTP. it is easy or very much tough. please tell me
What are the 2 ways in which a variable can be declared in the vbscript language?
Explain the functionality of vbscript?
What aspects of vbscript make it safe so that a web page using vbscript cannot destroy or corrupt information on a user's computer?
Program to use input box and send even numbers into sheet1 and odd numbers into sheet2 and prime numbers into sheet3 using vbscript(QTP)?
Explain How do you create a recordset object in vbscript?
How will you get a string with the specified character the specified number of times in vbscript?
How can you destroy an object in vbscript?
What are events in the vbscript language?
I want to run QTP script on Linux server is it possible to do this by connecting Windows to Linux through VPN/Terminal Server and just run the script on Linux server.
What is the difference between function and procedure?
What is the use of the ‘open’ method to work with the database in the vbscript language and what connection string is passed in the same and what is its usage?