/** The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. */ #include "0.hpp" #include uu factor(uu a, uu min = 1) { uu temp = min; uu sqr = (int)(sqrt((double)a) + _eps); while(temp < sqr) if(a % ++temp == 0) break; if(a % temp == 0) return temp; else return 1; } int main() { const uu _max = 2000000; uu sum = 0; timeb start, end; ftime(&start); for(uu i = 3; i <= _max; i += 2) { if(factor(i) == 1) { //cout << i << "\t"; sum += i; } } sum += 2; ftime(&end); cout << sum << endl; cout << (end.time - start.time) * 1000 + end.millitm - start.millitm << endl; return 0; }