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);
}
}
}
}
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);
}
}
}
}
See Other Tutorial :
* AngularJS Crude With ASP.NET MVC
* Convert Rows to columns using 'Pivot' in SQL Server
* Mvc Registration page With user exist using Ajax method
* MVC 4 How to Perform Insert Update Delete Edit Select Operation
* MVC4 Edit,update,Delete,cancel inside gridview using sql database
* MVC 4 Gridview To Display Data Using SQL Server Database With Simple code
* Login page in asp.net Mvc4 Web application
* Mvc4 How to bind Dropdown List using Sql Database
* Gridview find control in asp.net
Sign up here with your email
ConversionConversion EmoticonEmoticon