1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class Sample { public: unsigned int sumOfPrimes(unsigned int max) { unsigned int total = 0; for (unsigned int i = 2; i <= max; i++) { for (unsigned int j = 2; j < i; j++) { if (i % j == 0) { goto next; } } total += i; next:; } return total; } };