Exemplo n.º 1
0
        public void PrimeTest10()
        {
            int actual   = PrimeNumberGenerator.GetPrimeNumber(10);
            int expected = 29;

            Assert.Equal(expected, actual);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            bool proceed      = true;
            bool intIsSuccess = false;

            Console.WriteLine("Let's locate some primes!\n");
            Console.WriteLine("This application will find you any prime, in order, from the first prime number on.");

            while (proceed)
            {
                intIsSuccess = false;
                int getPrime = 0;
                while (!intIsSuccess)
                {
                    Console.Write("Which prime number are you looking for? ");
                    intIsSuccess = int.TryParse(Console.ReadLine(), out getPrime);
                }

                int myPrime = PrimeNumberGenerator.GetPrimeNumber(getPrime);
                Console.WriteLine($"The number {getPrime} prime is {myPrime}.\n");
                Console.Write("Do you want to find another prime number? (y/n): ");
                string response = Console.ReadLine().ToLower();
                if (response == "y")
                {
                    proceed = true;
                }
                else
                {
                    proceed = false;
                }
            }

            Console.WriteLine("Thank you and good-bye!");
        }
Exemplo n.º 3
0
        public void PrimeTest7()
        {
            int actual   = PrimeNumberGenerator.GetPrimeNumber(7);
            int expected = 17;

            Assert.Equal(expected, actual);
        }