Created
February 10, 2026 05:59
-
-
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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