Skip to content

Instantly share code, notes, and snippets.

@dgodfrey206
Created February 10, 2026 05:59
Show Gist options
  • Select an option

  • Save dgodfrey206/72e021d7eb186a55bf032d3252722e84 to your computer and use it in GitHub Desktop.

Select an option

Save dgodfrey206/72e021d7eb186a55bf032d3252722e84 to your computer and use it in GitHub Desktop.
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
#include <bits/stdc++.h>
#include <cassert>
using namespace std;
int main() {
int n = 40;
while (true) {
bool found = true;
for (int i = 2; i <= 20; i++) {
if (n % i != 0) {
found = false;
break;
}
}
if (found)
break;
n++;
}
cout << n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment