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
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 |
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 |
How will you get the natural logarithm of the given number in vbscript?
write a vb script to display the size of the folder,date created and name of the folder
How to get the background color of a weblist?
write a program to display configuration of a local system with the help of vb script.
Plzzzzzzz can any one tell me which is the best institute in hyderabad for learing VBScript. plz do answer guys its urgent plzzzzzzz. thanks in advance.
What is the main difference between function and sub-procedure?
how to declare a variable in vbscript using vbscript
Write a vbscript procedure that converts feet to inches. Hint: there are 12 inches in a foot?
what is resorceallocation
What are subprocedures in vbscript?
what is the features of visual basic?
If a calulator having 3 buttons (of any number)in 3 of them one is not working properly due to which answer is wrong always. write a script to find out which button is not working properly ?