Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Wednesday, 23 May 2018

Write a VB Script to check whether a given number is prime or not?



Method-1

a = cint(Inputbox("Enter a number to check whether it is a prime number or not"))
count = 0
b = 1
Do while b<=a
aaaif a mod b = 0 Then
aaaaaacount = count +1
aaaEnd If 
b=b+1
Loop
If count = 2 Then
aaamsgbox "The number "&a& " is a prime number" 
Else 
aaamsgbox "The number "&a& " is not a prime number"
End if


Method-2


val=Inputbox("Please enter any number")
valprime = 0
For i=2 to Int(val/2)
aaaIf val mod I = 0 Then
aaamsgbox "The number"&val&" is not a prime number"
aaavalprime=1
aaaExit for
End If
Next
If valprime=0 Then
aaamsgbox "The number"&val&" is a prime number"
End If



No comments:

Post a Comment

Note: only a member of this blog may post a comment.