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
[php]
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("—————————————")
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
Next
If count = 2 Then
Console.WriteLine("{0} is a Prime Number." & vbLf, number)
Else
Console.WriteLine("{0} is not a Prime Number." & vbLf, number)
End If
Console.ReadKey()
End Sub
End Class
End Namespace
[/php]
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.
great content. Keep on posting like this post