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


Please Help Members By Posting Answers For Below Questions

Explain some uses of vb script?

549


Write a code to print numbers from 5 to 0?

673


Explain few date functions in vbscript?

612


What is the use of option explicit statement?

581


Mention what is variant in vbscript?

552






Mention what is the use of option explicit in vbscript?

544


What is vbscript?

593


When does ‘on click of button’ event gets triggered in the vbscript language?

538


Why to use option explicit in vb script?

592


how to automatically update the sql server2005 database records when insert in vb6?

1483


Mention the rules for using option explicit statement?

480


Explain a few date functions in vbscript

553


Explain different types of segment?

565


What is the technology used by vb script?

539


Which function is used to perform string comparison?

559