IsPrime() public method

public IsPrime ( int n ) : bool
n int
return bool
Ejemplo n.º 1
0
 static void Main(string[] args)
 {
     Program p = new Program();
     int n = 1;
     List<int> list = new List<int>();
     while (list.Count < 1000)
     {
         if (p.IsPrime(n))
             list.Add(n);
         n++;
     }
     Console.WriteLine(list.Sum());
     Console.ReadLine();
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Program    p    = new Program();
            int        n    = 1;
            List <int> list = new List <int>();

            while (list.Count < 1000)
            {
                if (p.IsPrime(n))
                {
                    list.Add(n);
                }
                n++;
            }
            Console.WriteLine(list.Sum());
            Console.ReadLine();
        }