Interview Questions   Tutorials   Discussions   Programs   Videos

# QTP - Write VB script to test given number is Prime Number?

439
views
asked marvit October 10, 2014 10:07 AM

Write VB script to test given number is Prime Number?

'VBScript program to display the prime numbers PrimeNumberLimit = inputbox("Enter the range till (ex: 50):") 'Getting the limit as an input from the user

PrimeNumberList="Prime number list is:" 'Initialising the list of prime numbers

PrimeFlag=True ' Initialising a Flag variable

If Ctr1>=4 Then

For Ctr2=2 to Ctr1/2

If Ctr1 mod Ctr2 = 0 Then 'Checking the reminder

PrimeFlag=False
'Not a prime number

End If

Next

End If

If PrimeFlag=True Then

'Collecting the prime numbers

End If

Next

flag

'VBScript program to display the prime numbers PrimeNumberLimit = inputbox("Enter the range till (ex: 50):") 'Getting the limit as an input from the user

PrimeNumberList="Prime number list is:" 'Initialising the list of prime numbers

PrimeFlag=True ' Initialising a Flag variable

If Ctr1>=4 Then

For Ctr2=2 to Ctr1/2

If Ctr1 mod Ctr2 = 0 Then 'Checking the reminder

PrimeFlag=False
'Not a prime number

End If

Next

End If

If PrimeFlag=True Then

'Collecting the prime numbers

End If

Next

flag

### Join with account you already have

Preview

Online-Classroom Classes
www.writeabc.com

1 person following this question

1 person following this tag

Question tags

qtp × 1

Asked 2 years and 3 months ago ago
Number of Views -439