Write VB script to test given number is Prime Number
Answers were Sorted based on User's Feedback
Answer / vijay kumar
Dim n
count=0
n=inputbox("enter a number")
For i=2 to n-1
If n mod i=0 Then
count=count+1
End If
Next
If (count/2)<> 0 Then
print "given number is normal number"
else
print "given number is prime number"
End If
Is This Answer Correct ? | 41 Yes | 14 No |
Answer / apoorva
bresult = False
Num = 907
For i = 2 To Num / 2
If Num Mod i = 0 Then
bresult = True
Exit For
End If
Next
If bresult = True Then
MsgBox "Prime"
Else
MsgBox "Not Prime"
End If
Is This Answer Correct ? | 7 Yes | 3 No |
Answer / kishore
Dim n
count=0
n=inputbox("enter a number")
For i=2 to n-1
If n mod i=0Then
count=count+1
End If
Next
If count>3 Then
print "given numer is normal number"
else
print "given number is prime number"
End If
Is This Answer Correct ? | 31 Yes | 37 No |
Answer / prasanth
Dim n
count=0
n=inputbox("enter a number")
For i=2 to n-1
If n mod i=0Then
count=count+1
End If
Next
If count>1 Then
print "given numer is normal number"
else
print "given number is prime number"
End If
Is This Answer Correct ? | 8 Yes | 15 No |
Answer / rvanamala
'--------- "n" is a given number
n = 101
retval= PrimeNo(n)
If strComp(retVal,"1",1) =0 Then
MsgBox n &" is a Prime Number"
Elseif strComp(retVal,"0",1) =0 Then
MsgBox n &" is not a Prime Number"
Else
MsgBox n &" is -ve Number"
End If
'-------------------
Function PrimeNo(x)
k=0
z=0
If strComp(n,"0",1) = 0 Then
PrimeNo = 0
Exit Function
Elseif n < 0 Then
PrimeNo = -1
Exit Function
End If
For i = 1 to x
IsPrime = 0
If strComp(x,"1",1)= 0 Then
PrimeNo = 0
Exit Function
End If
z = x mod i
If eval("z = 0") and strComp(i,x,1) <>0 and
strComp(i,"1",1) <> 0 Then
PrimeNo = 0
Exit Function
Else
IsPrime= 1
End If
Next
PrimeNo = IsPrime
End Function
'-----------------------------------
Is This Answer Correct ? | 0 Yes | 10 No |
Pls let me know how to find out creation time and index for the web application in descriptive programming?
Actually How do we use this Smart Identification Technology during Recording mode.
how to capture data from images in QTP and produce them in excel sheet?
do you prepared framework,pls answer this
What is the difference between shared and local object repository?
Explain quicktest professional (qtp) testing process?
Hi, one script having 10 Actions,but i want to execute only 3rd action and 7th action? how to execute selected actions? throgh script and through navigation?
please tell me how to identify the index of the link in the web table .links are not constant.example i want to click the link in the inbox ,search the item and click the partcular mail.(mail links count is not constant)
What are the general steps involved in the data driven framework?
How many types of recording facility are available in quicktest professional?
What is checkpoints for quicktest professional (qtp)?
what is difference betweem class annd object?