find prime number or not in asp classic

santhosh d
santhosh d used Ask the Experts™
on
<%
 
        Dim number,i
            number= 7
                if number mod 2 <> 0 Then
             For i = 1 To 10
            Next
            
            end if
             
            If number mod i = 1 Then
             response.write number &"is  a  prime number"    
Else
            response.write number &"Number is not  Prime"                   
            End If
         
        %>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software Team Lead
Commented:
<%
        for i = 0 to 150
            if isPrime(i) Then
                response.write "<font color='red'>" & i &" is a prime number</font><br>"    
            Else
                response.write i &" is not prime number<br>"                  
            End If
        next
        
        function isPrime(number)
            Dim i
            isPrime = true
            if number < 2 then
                isPrime = false
            else
                for i = 2 to number-1
                    if number mod i = 0 then
                        isPrime = false
                        exit function
                    end if
                next
            end if
        end function
%> 

Open in new window

Ryan ChongSoftware Team Lead

Commented:
Proposed solution answered the question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial