示例#1
0
        static void Main(string[] args)
        {
            int index, menu, prime;

            do
            {
                menu = IntInput("1. Give index and recieve prime.\n2. Give prime and recieve index.\n(Input a number lower than 1 to quit) >> ");
                switch (menu)
                {
                case 1:
                    index = IntInput("Enter a prime index to see prime >> ");
                    prime = PrimeNumbers.GeneratePRime(index);
                    Console.WriteLine($"Index: {index} Prime: {prime}\n");
                    break;

                case 2:
                    prime = IntInput("Enter a prime number and see its index >> ");
                    if (PrimeNumbers.CheckPrime(prime))
                    {
                        index = PrimeNumbers.PrimeIndex(prime);
                        Console.WriteLine($"Prime: {prime} Index: {index}\n");
                    }
                    else
                    {
                        Console.WriteLine("That is not a prime number, please try again!\n");
                    }
                    break;

                default:
                    break;
                }
            } while (menu > 0);
        }
示例#2
0
        static void Main(string[] args)
        {
            int num;

            Console.WriteLine("Enter the Number ");
            num = int.Parse(Console.ReadLine());
            PrimeNumbers p1 = new PrimeNumbers(num);

            int primenum = PrimeNumbers.GivePrime(num);

            Console.WriteLine(primenum);
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("PRIME NUMBER CHECKER");

            string rerun = "";

            do
            {
                Console.WriteLine("====================================================");
                Console.Write("What prime number would you like to check: Enter number 1-10 ");
                int input = int.Parse(Console.ReadLine());

                Console.WriteLine($"The prime number at position #{input} is {PrimeNumbers.GetPrime(input)}");

                rerun = Rerun(rerun);
            }while (rerun == "y");

            Console.WriteLine("Bye. Thank you for using the prime number checker!!!");
        }