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
Explain a few date functions in vbscript
How will you convert a given number to long in vbscript?
How can you destroy an object in vbscript?
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
did any one attended interview in applabs if you had gone through plz tell me the procedure
Mention what are the rules to name variable in vbscript?
how to automatically update the sql server2005 database records when insert in vb6?
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?
Like OPTION EXPLICIT statement what are the other statements used in vbscript and their usage. Please post me all the statements please.
Is VB Script Case sensitive or Case insensitive?
Explain about tristate constants?
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.
Explain about scrrun.dll in vbscript?
How to make sure that items in a wintree are sorted al?
Mention how to assign a date value to a variable?