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


Please Help Members By Posting Answers For Below Questions

what is the object hyrarchy in QTP for a web based application

1887


Explain the asc function?

508


How to add actions in driver script to run those actions in QTP?

1520


Which function is used in the vbscript language to convert the specified expression into a date type value?

525


what is resorceallocation

1775






Which event is triggered when mouse focus comes out of an element in the vbscript language?

512


How to get the length of the string by making use of the string function?

569


while using Keyward driven framework in QTPif new requirements are added how to manage it...plz ans

1568


What is purpose of scripting.filesystemobject class in vbscript?

627


What are the properties of regexp object?

581


Compare java script and vb script?

595


How to capture a runtime error in vbscript?

630


How will you get a string with the specified character the specified number of times in vbscript?

577


What are class properties?

657


What are class variables?

619