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 open excel in vb script?

0 Answers  


Plz give the vb script for the following scenerio. In travel booking we have to select from delhi to mumbai from the combobox The prices will be display in another combo box .But i have to select the lowest price for it and submit it

1 Answers   IBM,


Hi All, I am facing one problem in QTP. There is link object in my application that exist in the Frame in mozilla firefox. Click event on that object is not working but once the frame is enabled/activated then click event works fine.But the frame does not have the activate property. This problem is coming in firefox only. Regards

0 Answers  


* ** *** Please write a code to get output like above diagram? ple explain as it how the code works?

2 Answers  


What is the output of a + b in vbscript if a = 5 and b = 10?

0 Answers  


wht must be the interview question on corinthian information technology solutions incorporated.

0 Answers   HP,


How will you reverse a string in vbscript?

0 Answers  


Like OPTION EXPLICIT statement what are the other statements used in vbscript and their usage. Please post me all the statements please.

0 Answers   Accenture,


How to generate 3 digit random number?

3 Answers   IBM, Virtusa,


write a vb script to display factorial of a number using function

1 Answers  


Write a function for Instr(). We need to write a function that works as same as Instr(). Code or Even pseudo code is good enough for me.?

0 Answers   Microsoft,


What is the main difference between function and sub-procedure?

0 Answers  


Categories