Write VB script to test given number is Prime Number
Answer Posted / 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 View All Answers
How to give a call to another action from one action?
What is the use of sendkeys and what are send keys
Dear sir, i want to perform a QTP automated testing for mechancial engineering software like msc adams, msc nastran this softwares will help for mechanical engineering design analysis>> i know oad runner win runner, test director, QTp>> but i dont know how to use for automation
What is different command used in command Prompt while using QTP?
Explain qtp(quick test professional)?
How to use actions in qtp ?
terminal services client
How to check feasibility of the appliction?in automation testing?
Explain the concept of object repository?
Describe how Smart Identification is used
How to find a window is minimized or not
What are the types of object repository?
What is a reusable action?
Hi all Can u give me the link where we can download full version of qtp my mail id is karthic.venkitapathi@gmail.com
How you can delete excel file in qtp?