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
What is the difference between a dictionary and an array?
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
Is VB Script Case sensitive or Case insensitive?
How to Enter Values on the Command promt using VB script
How to identify column in VSFlexgrid? My VSFlexgrid window is identified as 'Active X Control'
How to access array data?
What is the difference between for loop and while loop?
Write a Script for ATM in QTP
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
What is the purpose of drive object of scripting.filesystemobject class in vbscript?
What are lbound and ubound in the vbscript language?
How will you get the octal value of the given number in vbscript?
Mention what is the use of option explicit in vbscript?
How to Import data from a file (file is on the desktop) to the data table
why variable name should not exceed 255 characters?