Friday, 5 July 2013

Prime Number Between Two numbers:

 

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Two Numbers");
            Console.WriteLine("Enter First Number");
            int i = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter second number");
            int j = Convert.ToInt32(Console.ReadLine());
            for (int k = i; k <= j; k++)
            {
                int count = 0;
                for (int l = 1; l <= k; l++)
                {

                    if (k % l == 0)
                    {
                        count++;
                    }

                }
                if (count == 2)
                {
                    Console.WriteLine(k);
                }
            }
            Console.ReadLine();


        }
    }
}

No comments:

Post a Comment