Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
271 B
2
Indexable
Never
#include <iostream>

int LCM(int a, int b, int c) {
    int i = 2;
    while (true) {
        if (i % a == 0 && i % b == 0 && i % c == 0) {
            return i;
        }
        else i++;
    }
}
int main() {
    std::cout << "LCM: " << LCM(18, 20, 45);
    return 0;
}
Leave a Comment