2014-06-01から1日間の記事一覧

Project Euler 22

PE C#

Problem 22 MatchCollection と Linq を連携させるには、Cast<Match>() が必要。 Linq のメソッドチェーンで改行するさい、インデントを深くすべきか考え中。 using System; using System.IO; using System.Text.RegularExpressions; using System.Linq; class PE02</match>…

Project Euler 21

C# PE

Problem 21 d(n) の計算は、素直に割り算している。 using System; class PE021 { static int SumProperDivisors(int n) { int sum = 0; for (int i = 1; i*2 <= n; i++) { if (n % i == 0) { sum += i; } } return sum; } static int Calc() { int ans = 0;…