1
At first, do not use using namespace std
.
2
You do not use any function from "math.h"
header so you do not need to include it.
3
Next, using #include <windows.h>
is also bad. You use it only for time measure. Standard C++
library has a dedicated header for this purpouse. It will make code more portable. Example:
#include <chrono>
// ... some code
auto startTime = std::chrono::high_resolution_clock::now();
// do calculations
auto endTime = std::chrono::high_resolution_clock::now();
// output
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count();
std::cout << "Total time: " << duration << " milliseconds.";
4
main
function should always return int
, and accepted arguments are either none or
(int, char* [])
5
Instead of #define
macro, C++
uses const
keyword:
const int runs = 1000;
i=i+2
one iteration followed by ani=i+4
the next iteration (because every third increment of 2 is also divisible by 3). So: 5 -> 7 -> 11 -> 13 -> 17 -> 19 ... Basically this is equivalent to cutting out all 2 and 3. \$\endgroup\$