Added previous arduino implementations.
This commit is contained in:
21
Problem1.cpp
Normal file
21
Problem1.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user