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 / pankaja yathindrakumar

' Script to find if the given number is Prime or Not
Function Prime(n)
If n<=1 Then
Exit Function
Else
Flag="Prime"
For i=2 To n-1
If n Mod i=0 Then
Flag ="Not Prime"
End If
Next
End if
Prime=Flag
End Function
Res=Prime(6)
MsgBox Res

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about the extension .hta?

849


Hi All, I am facing one problem in QTP. There is link object in my application that exist in the Frame in mozilla firefox. Click event on that object is not working but once the frame is enabled/activated then click event works fine.But the frame does not have the activate property. This problem is coming in firefox only. Regards

2480


What is the purpose of regexp object in vbscript?

779


Develop a parameterized action that accomplishes the following a. Launch a browser of users choice ( example : IE, chrome etc) b. Open up a search engine (Google, Bing etc) c. Perform a search d. Click a particular link depending on the user’s choice ( 1st , 2nd or third link)

1633


How to use QTP Object in .vbs(vbscript file) file Ex: Browser().., wait(), exist() and etc...

3156


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

2003


By default in vbscript the arguments passed to functions and subroutines are by reference or by value?

838


Mention when to use function procedures and what are its characteristics?

850


What is the output of a + b in vbscript if a = 5 and b = 10?

2774


what is the use of QCUtil? explain with one example?

6667


Explain about the functionality of vb script?

772


hi Set myobj=Description.Create() myobj("type").value="submit" myobj("name").value="google search" myobj("html tag").value="button" browser("title:=google").page("title:=google").webButton (myobj).Click i was running above code in one weak back it was working fine i got result,again i opened after few days ,again i was trying to run the code it shows run time error in last line of my code ,why ?pls answer my question?

1984


Could Anybody Please tell me What is the script for Find 3rd Largest element in the Array without using a SORT function int Find(int arr[], int size); Thanks in Advance..

2270


What is byref and byval parameters in vbscript?

826


How to replace junk code recorded by QTP with a mall function.

1866