Prime Number Program in VB.Net

In this article, we will see Prime Number Program in VB.Net.

Prime Number Program in VB.Net
A prime number is a number that is divisible only by 1 and itself.
For example :
5 is a prime number as it is divisible by 1 and 5.
6 is not a prime number as it is divisible by 1,2,3 and 6.

Program :Prime Number Program in VB.Net
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks

Namespace ConsoleApp1
Class Program
Private Shared Sub Main(ByVal args As String())
Dim number As Integer
Dim count As Integer = 0
Console.Write("Check whether a number is Prime or not :" & vbLf)
Console.Write(vbLf & vbLf)
Console.Write("Enter an number : ")
number = Convert.ToInt32(Console.ReadLine())

For i As Integer = 1 To number

If number Mod i = 0 Then
count += 1
End If

If count = 2 Then
Console.WriteLine("{0} is a Prime Number." & vbLf, number)
Console.WriteLine("{0} is not a Prime Number." & vbLf, number)
End If

End Sub
End Class
End Namespace


Result :


If This article helped you. Humble request to you please donate small amount only 5 Ruppes or 1 Ruppes so that I can help the needy poor people. Send amount this phonepe upi id : 8800846247@ybl or google pay 8800846247. Thank you from my bottom of heart.

1 thought on “Prime Number Program in VB.Net

Leave a Reply

Your email address will not be published. Required fields are marked *