We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Wednesday, June 10, 2015

Find the prime number between Given the range max and min value.


    class Program 
    { 
        static void Main(string[] args) 
        {

            int i, j, count, min, max;

            Console.WriteLine("Enter the minimum value");

            min = int.Parse(Console.ReadLine());

            Console.WriteLine("Enter the maximum number");

            max = int.Parse(Console.ReadLine());


            if (min == 0)

                min = min + 1;

            Console.WriteLine("Prime number between min and max {0},{1}", min, max);

            for (i = min; i <= max; i++) 
            { 
                count = 0;

                for (j = 2; j <= i / 2; j++) 
                { 
                    if (i % j == 0) 
                    { 

                        count++;

                        break;

                    }

                } 

                if (count == 0 && i != 1) 

                    Console.Write(i + " ");

            }

            Console.ReadLine(); 
        }


    }

No comments: