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 / pankaja yathindrakumar
' Script to find if the given number is Prime or Not
Function Prime(n)
If n<=1 Then
Exit Function
Else
Flag="Prime"
For i=2 To n-1
If n Mod i=0 Then
Flag ="Not Prime"
End If
Next
End if
Prime=Flag
End Function
Res=Prime(6)
MsgBox Res
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What purpose does ‘on error resume next’ serves?
How to write functions and sub in vb script?
Which in-built function is used to format the number in the vbscript language?
What are the rules to name variable in vbscript?
Explain the functionality of vbscript?
How will you reverse a string in vbscript?
If we take 2 strings as “good” and “bad” then what will ‘+’ and ‘&’ operators return?
What are the properties of regexp object?
What is event handling in vbscript?
How to pass argument by reference to a function in vbscript?
There are 5 web pages.write a script to click the button on 4th web page.
can anyone send me a vb scripts code for clicking on a link and coming back on home page again does the same for many links on a web page.
Mention what is variant in vbscript?
How to Import data from a file (file is on the desktop) to the data table
Set srchobj=Description.Create() srchobj("type").value="text" srchobj("name").value="q" srchobj("html tag").value="input" browser("micclass:=google").Page("micclass:=google").webedit (srchobj).Set "qtp" what's wrong in my code pls tell me ? the above code working fine and i got my result pass,now i am trying to run the program it shows general run time error why?pls help me i am in learning stage ?