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 can we retrieve the Bug Ids which are open&Reopen in status through QTP scrit?Please find the script which i tried... Dim objBugFactory, objBug Dim BugId Set TDConnection = QCUtil.TDConnection Set objBug = TDConnection.BugFactory If QCUtil.IsConnected then Reporter.ReportEvent 0, "Connected", "Connected to server: " + QCUtil.TDConnection.ServerName + chr (13) +"Project: " + QCUtil.TDConnection.ProjectName + chr (13) + "Domain: " + QCUtil.TDConnection.DomainName Reporter.ReportEvent 0, "Current time on server is","==>" & TDConnection.ServerTime Else Reporter.ReportEvent 1, "Not connected", "Not connected to Quality Center" End If If mybug.Status="Open" Then BugId=mybug.DefectId MsgBox BugId End If 'OR**********************************--------------------- -----********************************** If Bug_Fields("BG_STATUS").Value ="Open" Or "Re Open"Then BugId=Bug_Fields("BG_BUG_ID").Value MsgBox BugId End If
How to customize qtp?
Can any give an example(if possible templates) how to test web application using QTP. thanks in advance
How would you export a script from one pc to another in qtp?
Is it possible to change the values of analog recording?
Define Canvas view of UFT?
I am Facing Issues with learing datepicker 1)when i first learn datepicker as current system date . 2)if i wanna runtime datepicker value it gives error
how to create flat file datasubmission in qtp
How to suppress warnings from the test results page?
Does any one worked on JIL Emulator , Testing with QTP(automation). Trail Version of QTP is not identifying the child objects of JIL emulator, Can any one help me out ,
If the objects hierarchy is changing from build to build, then how you will handle that condition?
Hi All, How to Compare two strings character by character in QTP
What are the data types in qtp?
What is parameter in qtp?
how we connect 1. qtp9.2 to the quality center9.0? 2. Load runner8.0 to the quality center9.0