2013-10-01から1ヶ月間の記事一覧

Project Euler 8

PE

Problem 8 char.IsDigit(c) で文字 c が数値かどうか判定 文字 c から数値への変換は、c - '0' で出来た using System; using System.IO; using System.Collections.Generic; namespace PE { public class PE008 { public static void Calc() { string text …

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</int>…

Project Euler 6

Problem 6 using System; namespace PE { public class PE006 { public static void Calc() { int sumsq = 0; for (int i = 1; i <= 100; i++) { sumsq += i * i; } int sqsum = (int)Math.Pow(100 * 101 / 2, 2); Console.WriteLine(sqsum - sumsq); } } }