Project Euler 7

Problem 7

using System;
using System.Collections.Generic;

namespace PE {
    public class PE007 {
        public static void Calc() {
            var primes = new List<int>();

            for (int i = 3; /* none */; i += 2) {
                bool isprime = true;
                foreach (int x in primes) {
                    if (x * x > i)
                        break;

                    if (i % x == 0) {
                        isprime = false;
                        break;
                    }
                }

                if (isprime) {
                    primes.Add(i);
                    if (primes.Count == 10001 - 1) { // -1 は素数 2 の分
                        Console.WriteLine(primes[primes.Count - 1]);
                        break;
                    }
                }
            }
        }
    }
}