Micro Focus QTP (UFT) Forums
VB Script - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: VB Script (/Thread-VB-Script--2678)



VB Script - shwetap - 11-11-2009

VB script to check a number is prime or not


RE: VB Script - Tarik Sheth - 11-11-2009

Code:
For x = 3 To 200 Step 2
      bIsPrime = True
      For y = 2 To x\2
         bIsPrime = x mod y > 0
         If Not bIsPrime Then Exit For
      Next
' check if the bIsPrime returns true if yes then it is prime.
      
  If bIsPrime Then
         document.writeln("Found a prime number: " & x)  
      End If
   Next
[/align]

by the way did you google it?