Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USING C#, CANNOT USE LINX! Write a console application that will allow the user

ID: 3727589 • Letter: U

Question

USING C#, CANNOT USE LINX!

Write a console application that will allow the user to input any integer of type int64 and determine whether or not the number is a prime number. The program should contain a query controlled loop allowing the user an option to rerun the program and enter an additional number(s). It should have a second component that is responsible for checking these 2 numbers and performing the timed test.

Determine if these 2 numbers are prime.

                 7389274937501454911;

                 9389274937501454911;

Rubric:

Correctly calculates prime or not prime 10 pts

Calculations for both numbers complete in 25 seconds or less 5 points

Use either a stopwatch or datetime now to demonstrate/verify the time required.

Explanation / Answer

using System;

namespace PrimeNumber
{
    class Program
    {
        static void Main(string[] args)
        {
            Check_Prime();
            Check_Prime();
            Console.Read();
          
        }

        private static int Check_Prime()
       {
           Console.WriteLine("Enter a number");
            int number = Convert.ToInt32(Console.ReadLine());
            int i;
            for (i = 2; i <= number - 1; i++)
            {
                if (number % i == 0)
                {
                    Console.WriteLine("{0} is not a prime number", number);
                }
            }
            if (i == number)
            {
                Console.WriteLine("{0} is a prime number", number);
            }
            return 0;
        }
      
    }
}