http://projecteuler.net/index.php?section=problems&id=47
順番に素数の個数を求めるだけ。
#include <iostream> #include "primes.h" using namespace itertools; int main() { const int M = 4; // number of primes const int N = 4; // number of consecution auto c = count<>(1); auto g = map([] (int n) { return std::make_tuple( (int)(list(primes::factorize(n)).size()), n); }, c); int s = 0; while(true) { auto t = g.next(); if(fst(t) == M) s++; else s = 0; if(s == N) { std::cout << snd(t) - N + 1 << std::endl; break; } } }