Write VB script to test given number is Prime Number

Answers were Sorted based on User's Feedback



Write VB script to test given number is Prime Number..

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

Write VB script to test given number is Prime Number..

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

Write VB script to test given number is Prime Number..

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

Write VB script to test given number is Prime Number..

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

Write VB script to test given number is Prime Number..

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

Post New Answer

More QTP Interview Questions

Pls let me know how to find out creation time and index for the web application in descriptive programming?

2 Answers   HP,


Actually How do we use this Smart Identification Technology during Recording mode.

1 Answers  


how to capture data from images in QTP and produce them in excel sheet?

3 Answers  


do you prepared framework,pls answer this

1 Answers  


What is the difference between shared and local object repository?

0 Answers  






Explain quicktest professional (qtp) testing process?

0 Answers  


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?

2 Answers   IBM,


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)

1 Answers   IBM,


What are the general steps involved in the data driven framework?

0 Answers  


How many types of recording facility are available in quicktest professional?

0 Answers  


What is checkpoints for quicktest professional (qtp)?

0 Answers  


what is difference betweem class annd object?

1 Answers  


Categories