FAtechs is a Web Site where you can find a lot of things related to tech and Education. Our Posts are mostly about Programming, Information, Technology,Software, Reviews & Everything You need to Know. You can also find Books and Novels here. Your appreciation and criticism will be welcomed.

Prime Numbers in C# Tutorial

Prime Number in C#:

Prime Numbers are the number which is not divisible by any
number. Prime Numbers are Only Divisible by its own. 0 and 1 are not Prime
Number as Prime Number starts from 2. Examples of Prime Numbers are 2, 3, 5, 7 ….

Prime number in C# can be calculated by various ways. We
will calculate it by Using for loop.

Code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace Prime_Number

{

classProgram

{

staticvoid Main(string[] args)

{

Console.WriteLine("Enter
number"); //Asking for the limit to which
prime numbers will be calculated

int upper_limit = Convert.ToInt32(Console.ReadLine());

for (int i = 2; i
< upper_limit; i++) // Prime Number Starts from 2 so we are starting loop from
2 to upper limit