2010-03-03から1日間の記事一覧

Project Euler 70

http://projecteuler.net/index.php?section=problems&id=70 pが大きい方から、素数の組(p, q) (p ≤ q)に対し、調べていく。 import Data.List is_prime n = all (\p -> mod n p /= 0) (takeWhile (\p -> p * p <= n) primes) primes = 2:(filter is_prime […

Project Euler 1(1)

そろそろC++の復習でもしようというのとVC10(C++0x)の機能の予習を兼ねてProject Eulerの問題を解いていく。 http://projecteuler.net/index.php?section=problems&id=1何も考えずに書くとこんな感じだろうか。 #include <iostream> using namespace std; const int </iostream>…