Exercise
Prime number
Objetive
Write a Visual Basic (VB.Net) program that asks the user for an integer and determines if it is a prime number or not.
Code
Imports System
Public Class exercise46
Public Shared Sub Main()
Dim number As Integer
Dim dividers As Integer = 0
Console.Write("Enter a number: ")
number = Convert.ToInt32(Console.ReadLine())
For i As Integer = 1 To number
If number Mod i = 0 Then dividers += 1
Next
If dividers = 2 Then
Console.WriteLine("The number is prime")
Else
Console.WriteLine("The number is not prime")
End If
End Sub
End Class