예제 #1
0
        static void Main(string[] args)
        {
            SmallPrimeGenerator generator = new SmallPrimeGenerator(2000000);
            double primeSum = 0;
            foreach (int prime in generator)
            {
                Console.WriteLine(String.Format("Adding prime {0}", prime));
                primeSum = primeSum + prime;
            }

            Console.WriteLine(String.Format("Sum of all primes under 2,000,000 is {0}", primeSum));
            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            SmallPrimeGenerator generator = new SmallPrimeGenerator(2000000);
            double primeSum = 0;

            foreach (int prime in generator)
            {
                Console.WriteLine(String.Format("Adding prime {0}", prime));
                primeSum = primeSum + prime;
            }

            Console.WriteLine(String.Format("Sum of all primes under 2,000,000 is {0}", primeSum));
            Console.ReadKey();
        }
예제 #3
0
        static void Main(string[] args)
        {
            SmallPrimeGenerator generator = new SmallPrimeGenerator(Int32.MaxValue/4096);

            int i = 1;
            int currentPrime = 1;
            foreach (int prime in generator)
            {
                currentPrime = prime;
                //Console.WriteLine(String.Format("{0} prime is {1}", i, currentPrime));
                if(i == 10001)
                {
                    break;
                }
                i = i + 1;
            }

            Console.WriteLine("10,001st prime {0}.", currentPrime);
            Console.ReadKey();
        }
예제 #4
0
        static void Main(string[] args)
        {
            SmallPrimeGenerator generator = new SmallPrimeGenerator(Int32.MaxValue / 4096);

            int i            = 1;
            int currentPrime = 1;

            foreach (int prime in generator)
            {
                currentPrime = prime;
                //Console.WriteLine(String.Format("{0} prime is {1}", i, currentPrime));
                if (i == 10001)
                {
                    break;
                }
                i = i + 1;
            }

            Console.WriteLine("10,001st prime {0}.", currentPrime);
            Console.ReadKey();
        }