by HDev is living On tHE EdgE on December 27th, 2007

HDev is living On tHE EdgE

Question

Help answer this question below.

Does anyone here know the Visual Basic coding to find whether a number is prime or not?

  • Like
  • Report

Answers



Answers. 1 helpful answer below.

  • by HDev is living On tHE EdgE on February 11th, 2008

    HDev is living On tHE EdgE

    Here it is

    private sub command_click()
    x = InputBox("Enter the number")
    j = 0
    If x = 1 Then
    Print "Neither Prime nor composite"
    End If
    For i = 1 To x
    If x Mod i = 0 Then
    j = j + 1
    End If
    Next i
    If j = 2 Then
    Print "Prime"
    ElseIf j <> 2 And x <> 1 Then
    Print "Composite"
    End If
    end sub

    • Like
    • Report

    1 comment | Post one | Permalink

Want to attach an image to your answer? Click here.

Did this answer your question? If not, then ask a new question or create a poll.

You're reading Does anyone here know the Visual Basic coding to find whether a number is prime or not?

Follow us on Facebook!

Related Ads

Related Questions

Answerbag