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.

Answer Posted / vinay vuppala

1st method


dim a
dim b
b=1
count=0
a=inputbox("enter a number")
for b=1 to a
if((a mod b)=0) then
count=count+1

end if
next
if count>2 then
msgbox("the number "& a &" is a not prime number")
else
msgbox("the number "& a &" is a prime")
end if

Is This Answer Correct ?    17 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

can anyone tell me the procedure of interview held in applabs

1757


Which constant is used for print and display functions and works as same as pressing enter key?

534


How to create a cookie using vbscript?

596


hi i am trying for testing job for 3+ experience(fake) can u suggest me what type of projects i can keep in my resume and how much of knoeledge i should have abt that project.thnks in advance.urgt plz

2591


i am having some basic knowledge in c and VB 6.0. i qtp i want to know how to write the codings. by recording it is generating lot of codings. for example i want to test the text box. senerio is text box should not accept alphabets if it accept alphabets we should return fail status if it get number we should return pass status. how to write coding in vb script please help me

1804






What is the extension of the vbscript file?

557


What's the difference between vbscript and vb.net?

559


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)

3195


Out of the different type of operators, which are evaluated first and last in the vbscript language?

570


How to take whole text output from screen of Bitmap Application.

1875


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

3281


Explain the scope of the variables using dim, public, and private keywords respectively.

726


what is used of Property........End Property loop ? how to write the script for it?

1694


If we take 2 strings as “good” and “bad” then what will ‘+’ and ‘&’ operators return?

539


How will you get a combined string from array of string in vbscript?

552