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 / ravi salunkhe
val=Inputbox("enter any number")
valprime=0
For i=2 to sqr(val)
If (val mod i)=0 Then
msgbox "not a prime number"
valprime=1
Exit for
End If
Next
If valprime=0 Then
msgbox "prime number"
End If
this will chop off the looping by limiting the loop to the
square root of the number!...\M/...mosh!
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What is the difference between for loop and while loop?
Explain sga memory structures?
I have an excel sheet with multiple ID's in a column. Now i need fetch those ID's in an application and check whether if it already exist in the DB. If not then i have to go with the process of inserting them in the DB. If it exists then i need to skip that ID and move to the next ID and check the same and proceed. How can i do that with for loop and if condition?
There are 5 web pages.write a script to click the button on 4th web page.
What are the differences between sub procedures and function procedures?
How to add actions in driver script to run those actions in QTP?
How should i Create Email invite with server-side Coding?
What are keywords in the vbscript language?
How can the spaces from the string be removed?
Which respective symbols are used to separate a line and to break the lengthy statement into multiple statements in the vbscript language?
while using Keyward driven framework in QTPif new requirements are added how to manage it...plz ans
how to operate webobjects in a webpage using getobject function and then using generic methods?
Explain the .wsf files?
about vb scripting programs this type of all question& answers
when we use filter funtiom invb script(QTP)