Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- typedef long long ull;
- ull gcd(ull a, ull b) {
- return b ? gcd(b, a % b) : a;
- }
- ull lcm(ull a, ull b) {
- return a / gcd(a, b) * b;
- }
- int main() {
- ull n;
- cin >> n;
- ull ans = 1;
- for (ull i = 1; i <= n; i++) {
- ans = lcm(ans, i);
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement