21 lines
433 B
C++
21 lines
433 B
C++
#include "Problem1.hpp"
|
|
|
|
Problem1::Problem1() {
|
|
input = 1000;
|
|
}
|
|
|
|
bool Problem1::Step() {
|
|
// add all factors of 3 under input
|
|
factor3 += 3;
|
|
if (factor3 < input) output += factor3;
|
|
|
|
// add all factors of 5 under input but skip factors of 3
|
|
factor5 += 5;
|
|
if (factor5 < input) {
|
|
factor5_tick++;
|
|
if (factor5_tick != 3) output += factor5;
|
|
else factor5_tick = 0;
|
|
}
|
|
|
|
return input < factor3 && input < factor5;
|
|
} |