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 / ravi salunkhe

val=Inputbox("enter any number")
valprime=0
For i=2 to sqr(val)
If (val mod i)=0 Then
msgbox "not a prime number"
valprime=1
Exit for
End If
Next
If valprime=0 Then
msgbox "prime number"
End If

this will chop off the looping by limiting the loop to the
square root of the number!...\M/...mosh!

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain a few date functions in vbscript

566


How will you convert a given number to long in vbscript?

498


How can you destroy an object in vbscript?

657


Sub link() Dim k As Integer Dim rand As Integer Dim URL As String Dim foldernum As Integer Dim folderstring As String Dim filenum As Integer Dim filestring As String k = 1 'for AC Numbers For i = 11 To 40 foldernum = 0 foldernum = 1000 + i folderstring = CStr(foldernum) folderstring = Mid(folderstring, 2, 3) folder = "ac" & folderstring 'folderstring = Sheets(2).Cells(i, 1) ' for Number of Random files For j = 1 To 10 rand = Int(Rnd * (200 - 1) + 1) filenum = 0 filenum = 1000 + rand filestring = CStr(filenum) filestring = Mid(filestring, 2, 3) 'URL = "http://ceobihar.nic.in/PSCDROM/ac" & folderstring & "/i" & folderstring & "0" & filestring & ".pdf" URL = "http://www.elections.tn.gov.in/pdfs/dt1/" & folder & "/" & folder & filestring & ".pdf" ' URL =http://www.wb.nic.in/wbeco/EROLLS/PDF/English/A001/a0010105 .pdf Cells(k, 1) = folderstring Cells(k, 2) = folder Cells(k, 3) = filestring Cells(k, 3) = URL k = k + 1 Next j Next i End Sub plz define it

2249


did any one attended interview in applabs if you had gone through plz tell me the procedure

1870






Mention what are the rules to name variable in vbscript?

544


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

1499


I have attended Anovatek Software QTP interview. They will give us computer and one web based application with QTP. We have to automate some records (already updated records or new records) using QTP Data driven testing. But we should use for loop? Can any one know how to do data driven testing using For loop?

1559


Like OPTION EXPLICIT statement what are the other statements used in vbscript and their usage. Please post me all the statements please.

1629


Is VB Script Case sensitive or Case insensitive?

644


Explain about tristate constants?

594


how to write a vb script in QTP for yahoo registration form, i want to check the performance also like performance test, stress, load test like that.

4755


Explain about scrrun.dll in vbscript?

668


How to make sure that items in a wintree are sorted al?

2362


Mention how to assign a date value to a variable?

596