There was an error while loading. Please reload this page.
2 parents 759fdc0 + 783c117 commit 5d2fad3Copy full SHA for 5d2fad3
Mathematics/GCD/Mathematics.cs
@@ -0,0 +1,34 @@
1
+using System;
2
+
3
+namespace TestMath
4
+{
5
+ public static class Mathematics
6
+ {
7
+ /// <summary>
8
+ /// Calcualtes Greatest Common Divisor of given 2 integers
9
+ /// </summary>
10
+ /// <param name="a"></param>
11
+ /// <param name="b"></param>
12
+ /// <returns></returns>
13
+ public static int GCD(int a,int b)
14
15
+ if (a % b == 0)
16
17
+ return b;
18
+ }
19
20
+ return GCD(b, a % b);
21
22
23
24
+ /// Calcualtes Least Common Multiple of given 2 integers
25
26
27
28
29
+ public static int LCM(int a, int b)
30
31
+ return Math.Min(a, b) * GCD(a, b);
32
33
34
+}
0 commit comments