summaryrefslogtreecommitdiff
path: root/PlaygroundCpp/Sources/Playground.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'PlaygroundCpp/Sources/Playground.cpp')
-rw-r--r--PlaygroundCpp/Sources/Playground.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/PlaygroundCpp/Sources/Playground.cpp b/PlaygroundCpp/Sources/Playground.cpp
index caa008b..2986140 100644
--- a/PlaygroundCpp/Sources/Playground.cpp
+++ b/PlaygroundCpp/Sources/Playground.cpp
@@ -12,34 +12,27 @@ static int getGCD(int a, int b) {
return getGCD(b, a % b);
}
}
-//TEST(FibLastDigitTest, Zero) {
-// ASSERT_EQ(getGCD(18, 35), 1);
-//}
-//
-//TEST(FibLastDigitTest, One) {
-// ASSERT_EQ(17657, getGCD(28851538, 1183019));
-//}
-//
-//TEST(FibLastDigitTest, Three) {
-// ASSERT_EQ(7, getGCD(1344, 217));
-//}
-//
-//TEST(FibLastDigitTest, Forty) {
-// ASSERT_EQ(1344, getGCD(1344, 1344));
+static long getLCM(int a, int b) {
+ // https://www.idomaths.com/hcflcm.php#formula
+ return (long) a * (long) b / (long) getGCD(a, b);
+}
+
+//TEST(LCMTest, Zero) {
+// ASSERT_EQ(getLCM(6, 8), 24);
//}
//
-//TEST(FibLastDigitTest, ThreeThreeOne) {
-// ASSERT_EQ(4, getGCD(14159572, 63967072));
+//TEST(LCMTest, One) {
+// ASSERT_EQ(getLCM(28851538, 1183019), 1933053046);
//}
//
-//TEST(FibLastDigitTest, ReverseAB) {
-// ASSERT_EQ(4, getGCD(14159572, 63967072));
+//TEST(LCMTest, Two) {
+// ASSERT_EQ(getLCM(14159572, 63967072), 226436590403296);
//}
int main() {
int a, b;
std::cin >> a;
std::cin >> b;
- int c = getGCD(a, b);
+ long c = getLCM(a, b);
std::cout << c << '\n';
}