View Single Post
  #1  
Old 17-06-2011, 09:52 PM
thecool's Avatar
thecool thecool is offline
Senior Member


 
Join Date: Apr 2009
Location: Multan
Posts: 1,163
Contact Number: Push me a PM if you really need
Program / Discipline: Alumni
Class Roll Number: ---
thecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond reputethecool has a reputation beyond repute
Smartass Prime number in c sharp

How to write prime number in c sharp
Code:
using System;
using System.Collections.Generic;
using System.Text;

namespace prime
{
class Program
{
static void Main(string[] args)
{
int no, i, flag;
flag = 1;
Console.WriteLine("Enter no. to be checked:");
no =Convert.ToInt16 ( Console.ReadLine());

for (i = 2; i <= no / 2; i++)
{
if (no % i == 0)
flag = 0;
}
if (flag == 1)
Console.WriteLine("Prime.");
else
Console.WriteLine("not Prime");
Console.ReadLine();
}

}
}

Reply With Quote