Prime number Programe using C#.net

How to Check the number is prime or not using C#.Net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace prime
{
    class Program
    {
        static void Main(string[] args)
        {
            int i, n;
            Console.WriteLine("enter the number:");
            n = Convert.ToInt32(Console.ReadLine());
          
          
            for (i = 2; i <=2; i++)
            {
                if (n % i == 0)
                    break;

            }
            if (i > 2)
                Console.WriteLine("prime number:", n);
            else
            {
                Console.WriteLine("not prime number:", n);
            }
        }
    }
}
Previous
Next Post »