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

Like OPTION EXPLICIT statement what are the other statements used in vbscript and their usage. Please post me all the statements please.

1625


Explain about arrays in vb script?

608


How to capture a runtime error in vbscript?

632


1) How can we use VB script in testing the application? 2) What all are the things(Software application to be installed in PC) we need to learn VBscript?

3558


Write a code to print numbers from 5 to 0?

688






I have attended Anovatek Software QTP interview. They will give us computer and one web based application with QTP. We have to automate some records (already updated records or new records) using QTP Data driven testing. But we should use for loop? Can any one know how to do data driven testing using For loop?

1553


What is the scope of a constant declared using public?

568


Which loop is used in case of arrays in the vbscript language?

527


What are the properties of regexp object?

583


Explain the functionality of vbscript?

541


How to write a VBscript for web page performance test i need a code send if any knows the code If any knows VBScript book plz send to me the link to my mail plz

2395


why variable name should not exceed 255 characters?

1823


How to declare an array in vbscript?

671


Explain the support of asp for vb script functionality?

641


Write program for identifyig duplicates in flight Departing from and Arriving in mercury tours(web application).

1444