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 / bhanu jay singh

<html>
<head>
<script language="vbscript" for="b1" event="onclick">
a=document.form.t1.value
for c=2 to a-1
if(a mod c)=0 then
x="no"
exit for
else
x="yes"
end if
next
if x="no" then
document.write("not a prime")
else
document.write("prime")
end if
</script>
</head>
<body>
<form name="form">
<input type="text" name="t1">
<input type="button" name="b1" value="find">
</form>
</body>
</html>

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between a dictionary and an array?

583


Dear All, I am geting below IE error whilie executing the QTP scripts in Batch mode "Internet Explorer has encountered a problem and needs to close. We are sorry for the inconvenience." can any one suggest me how to resolve this issue . Thanks Balaji

1247


Is VB Script Case sensitive or Case insensitive?

640


How to Enter Values on the Command promt using VB script

1534


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

3277






How to access array data?

545


What is the difference between for loop and while loop?

556


Write a Script for ATM in QTP

3345


Can any one provide code for Mid(string,start[,length]). I have been asked to write code for Mid(). i.e We need to define our own function say MyMid() which should behave same like built-in Mid function

1921


What is the purpose of drive object of scripting.filesystemobject class in vbscript?

610


What are lbound and ubound in the vbscript language?

609


How will you get the octal value of the given number in vbscript?

502


Mention what is the use of option explicit in vbscript?

551


How to Import data from a file (file is on the desktop) to the data table

1588


why variable name should not exceed 255 characters?

1822