Example #1
0
        public void CanIGetCount()
        {
            int            limit = 20;
            int            count = 8;
            PrimaryNumbers pn    = new PrimaryNumbers();

            Assert.AreEqual(count, pn.GetAllToLimit(limit).Count);
        }
Example #2
0
        public void CanIGetCorrectNumbers()
        {
            List <int> expected = new List <int>()
            {
                2, 3, 5, 7, 11, 13, 17, 19
            };
            PrimaryNumbers pn      = new PrimaryNumbers();
            List <int>     actual  = pn.GetAllToLimit(20);
            List <int>     actual2 = pn.Numbers;

            foreach (int exp in expected)
            {
                Assert.IsTrue(actual.Any(item => item == exp));
                Assert.IsTrue(actual2.Any(item => item == exp));
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.Write("Podaj gorny zakres liczb: ");

            int            limit  = Convert.ToInt32(Console.ReadLine());
            PrimaryNumbers pn     = new PrimaryNumbers();
            var            liczby = pn.GetAllToLimit(limit);

            foreach (var liczba in liczby)
            {
                Console.Write(liczba + " ");
            }
            Console.Write("\nPodaj dolny zakres: ");
            int d = Convert.ToInt32(Console.ReadLine());

            Console.
            WriteLine("Ilosc liczb pierwszych w przedziale {0} {1} to {2} ",
                      d, limit, pn.CountPrimaryNumbers(d, limit));
            Console.ReadKey();
        }