Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Could Anybody tell me VBScript for
Check if a given number is Prime number-Don't use any Built-
in Functions Boolean/int is Prime(int number).. Thanks in
advance.

Answers were Sorted based on User's Feedback



Could Anybody tell me VBScript for Check if a given number is Prime number-Don't use any Buil..

Answer / pankaj

Function IsPrime(Num)
Dim varNum, varCtr, varLimit
varLimit = Round(Num/2)

For varCtr = 2 To varLimit
varNum = Num Mod varCtr

If varNum = 0 Then
IsPrime = False
Exit For
End If
Next

If varCtr >= varLimit Then
IsPrime = True
End If
End Function

MsgBox IsPrime(19)

Is This Answer Correct ?    1 Yes 3 No

Could Anybody tell me VBScript for Check if a given number is Prime number-Don't use any Buil..

Answer / sayali

Dim prime, n

prime = TRUE

n=cint(inputbox("Enter a number to find whether it is Prime or Not"))

for i=2 to (n-1)

If n mod i = 0 then
prime = False

Exit for
End if
Next

If prime then
msgbox "Yes! It is a Prime number"
Else
msgbox "No! it is not a prime number"
End if

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More VB Script Interview Questions

How to access array data?

0 Answers  


Hi, Anybody could tell me What is the 3rd Largest Number in the series..Thanks in Advance..

3 Answers   Amazon, bcbs,


How to identify column in VSFlexgrid? My VSFlexgrid window is identified as 'Active X Control'

0 Answers  


which is the good software training centre in bangalore?

1 Answers  


Explain about scrrun.dll?

0 Answers  


what is visual basic?

2 Answers   Seion Infotech,


Both Static and dynamic arrays are handled by VB script. Is it true?

0 Answers  


Could Anybody tell me VBScript for Check if a given number is Prime number-Don't use any Built- in Functions Boolean/int is Prime(int number).. Thanks in advance.

12 Answers   Amazon, Pyroferus,


i need to sort the data using qtp script for this how i need to write a qtp script

0 Answers  


write a vb script to display the number is odd or even and whether it is divisible by 9 or not

2 Answers  


Write a Program to add 2 numbers without using operators (+,-) and without using third variable. Note: Use VBScript only Hint: You can use other operators like '/' & '*'(Division & Multiplication)

0 Answers   Quest,


Plzzzzzzz can any one tell me which is the best institute in hyderabad for learing VBScript. plz do answer guys its urgent plzzzzzzz. thanks in advance.

0 Answers  


Categories