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 ? | 42 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 |
What is the recovery scenario in qtp?
hi friends i have 4 yrs exp in testing and 2 yrsexp in QTP.currently aim working in mnc in north as a permanent employer .iam looking for job in south is there any openings plz let me know my mail id is bjr@aol.in its very urjent
what is the difference between the modular framework and datadriven frame work
in one page we have 100 links i have to click the 99th link how can i click the 99th link.
4 Answers GK Technologies, IBM,
How many types of parameters are available in quicktest professional (qtp)?
What are the Disadvantages of shared object repository?
In qtp is it possible to check broken links of a page?
What is the difference between Image Checkpoint and Bitmap Checkpoint?
hi i have one isuue on selecting webcheckbox .there are 15 wecheckboxex i want to select every time 9 th one how can i select plese help me regards balaji
what is the silent mode in WR?
Name the different types of recording modes?
How did you use regular expressions in QTP and also in WR?