Tag Archives: least common multiple

Make a Fraction class in C#

The Fraction class represent rational numbers using fractions, at least until the numerators and demoninators get too big. The Fraction class uses the following code, most of which is straightforward. class Fraction { public long Numerator, Denominator; // Initialize the … Continue reading

Posted in algorithms, classes, mathematics | Tagged , , , , , , , , , , , , , , , | 1 Comment

Calculate the GCD (greatest common divisor) and LCM (least common multiple) of two integers in C#

GCD The greatest common divisor of two integers is the largest integer that evenly divides them both. For example, GCD(180, 105) = 15 because 15 is the largest integer that divides evenly into both 180 and 105. Euclid’s Elements c. … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , , , | 2 Comments