<%
n = Request.Querystring("n")
If n < 100 Then : n = 100 : End If
If n > 10000 Then : n = 10000 : End If
Response.Write "<h2>Syntax</h2>" & vbNewLine
Response.Write "<p>To print the primes between 1 and 456, use"
Response.Write "<code><big><b>MathSamples.asp?n=456</b></big></code></p>" & vbNewLine
Response.Write "<h2>Output</h2>" & vbNewLine
Response.Write "<p>The primes between 1 and " & n & " are:" & vbNewLine & "<blockquote>" & vbNewLine
For i = 2 to n : If isPrime(i) Then : Response.Write i & " " : End If : Next
response.write vbNewLine & "</blockquote></p>" & vbNewLine
Function isPrime(i)
For j = 2 To Sqr(i)
If (i\j)*j = i Then : isPrime=vbFalse : Exit Function : End If
Next
isPrime=vbTrue
Exit Function
End Function
%> |
Syntax
To print the primes between 1 and 456, useMathSamples.asp?n=456
Output
The primes between 1 and 100 are:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
|