コード例 #1
0
        public static void SieveEratosthenes(int n)
        {
            Algorithm_Eratosthenes algorithm_Eratosthenes = new Algorithm_Eratosthenes();

            Console.WriteLine("SieveEratosthenes to {0}:", n);

            Console.WriteLine(string.Join(",", algorithm_Eratosthenes.Algorithm(n)));
        }
コード例 #2
0
        static void Main(string[] args)
        {
            int n;

            Console.WriteLine("Sieve of Eratosthenes");
            Console.WriteLine("this algorithm for finding all primes from the first prime number 2 to a given\n");

Break:
            Console.Write("Write your number N:");
            n = Convert.ToInt32(Console.ReadLine());

            if (n == 1 || n == 2 || n < 1)
            {
                Console.WriteLine("Please write N > 2");
                goto Break;
            }
            else
            {
                Algorithm_Eratosthenes.SieveEratosthenes(n);
            }

            Console.ReadLine();
        }