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

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

3 Answers   Amazon, bcbs,


explain with example primitive data types of vb script.

1 Answers  


How to remove the spaces in a string Ex: "Welcome to QTPWorld" ?

10 Answers   Cap Gemini, CTS,


Hello Guys, If any body looking for "worksoft certify tool training in bangalore", please contact me aimansaud@gmail.com

0 Answers  


How are values assigned to the variables in the vbscript language?

0 Answers  


Explain about operator precedence in vb script?

0 Answers  


Inorder to avoid Message box while writing script which alternative method can be used?

1 Answers  


how to write code: to check whether the window of an Application Under Test exist or not . plz give with example

2 Answers  


What is the difference between function and procedure?

0 Answers  


Explain the functionality of vbscript?

0 Answers  


Write a code to print numbers from 5 to 0?

0 Answers  


about vb scripting programs this type of all question& answers

0 Answers  


Categories