## C# Prime Number Program Tutorial with Examples

Today, We want to share with you **C# Prime Number Program Tutorial with Examples**.

In this post we will show you **Prime Number Program in C#**, hear for *C# Program to check if a number is prime or not* we will give you demo and example for implement.

In this post, we will learn about *Check a Number is Prime Number or not in C#* with an example.

## Prime Number Program in C#

In this post, we will learn about **Prime Number Program in C#** with an example.

Now in this post, I will explain **Prime Number Program in C#.Net ** with appropriate example. A prime number is a number which is greater than 1 and divided by 1 or itself. In other words, prime numbers cannot be divided by other numbers than itself or 1.

For example 2, 3, 5, 7, 11, 13, 17, 19, 23,29,31…. are the prime numbers.

### E-junkie: Sell digital downloads online

**E-junkie** Provides a Copy-paste buy-now, and cart buttons for selling downloads, codes and tangible products on any website, blog, social media, email and messenger!

**Also see:**

Now create Console Application in Visual Studio and write below lines of code in it.

using System; using System.Collections; using System.Collections.Generic; namespace infinityknow { class Program { static void Main(string[] args) { // Program to check whether the given number is prime or not int number, k, m = 0, flag = 0; Console.Write("Enter the Number to check Prime: "); number = int.Parse(Console.ReadLine()); m = number / 2; for (k = 2; k <= m; k++) { if (number % k == 0) { Console.Write("Number is not Prime."); flag = 1; break; } } if (flag == 0) Console.Write("Number is Prime."); Console.ReadKey(); // To retain the screen } } }

### Read :

### Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about **C# Prime Number Program Tutorial**.

I would like to have feedback on my Infinityknow.com blog.

Your valuable feedback, question, or comments about this article are always welcome.

If you enjoyed and liked this post, donâ€™t forget to share.