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 the functionality of vbscript?

542


How to identify column in VSFlexgrid? My VSFlexgrid window is identified as 'Active X Control'

3281


Description.Create

2165


what is event handling?

587


Which operator is used to concatenate the 2 values in the vbscript language?

563






Explain about vb script?

757


Mention what is vbscript?

602


How will you get the exponent of the given number in vbscript?

566


How will you get a subset of a array in vbscript?

593


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

2268


What is dictionary object in vbscript? Explain?

631


What are the environments supported by vbscript language?

509


How many types of procedures are available in the vbscript language?

539


how to operate webobjects in a webpage using getobject function and then using generic methods?

2549


For a webbased application:- what should be code in expert veiw, for retrieving a single column name "username" from a server and checking whether exported "username" from datatable doesn't exist in server. suppose i have saved in excelsheet a username="gayatri" , which is exported, then checked for whether this username "gayatri" exist in server database or not ? if exist then allow to enter new username, which should be again checked for in loop , or else come out of loop and enter a distinct "username". plz let me have this answer in my id gayatrisahooin@hotmail.com

1759