The Badb just had a couple of weeks of reviewing ratios. This was a good limbering-up exercise, since the problem sets were all about converting between different units and manipulating fractions. After all, ratios are just a different way of writing fractions. The general form of the problems wound up being, “Given that the ratio of thingumbob : doohickii is γ, how many doohickii are there if there are N thingumbobs?” She’d have to set up the equation and solve for the doohickii quantity.

In the evenings, this was really not a problem (until she got really tired) but first thing in the morning it was a tough job, converting from decimals to fractions, simplifying fractions, and doing other straightforward (at 4 in the afternoon) operations. So let’s think about fractions for a minute. There are really two major operations one performs on fractions: multiplication and addition. Multiplication is easy (numerator times numerator, denominator times denominator, simplify, done) but addition is kind of a pain; you have to have a common denominator. Finding any common denominator is easy (heck, just multiply each denominator by the other) but we would prefer to work with the smallest whole numbers we can get away with, because smaller numbers are easier to handle and because humans, at least the smart ones, are lazy and hate doing extra work. So what we want, given two denominators A and B, is to find the least common multiple (LCM) of the two numbers.

Let’s say we want a program that lets you input two fractions as four integers (numerator A, denominator A, numerator B, denominator B) and it will output the original fractions, the required multipliers, and the multiplied fractions which have common denominators. That is, it’ll take something like this:

5/6

7/10

and give you

5/6 * 5/5 = 25/30

7/10 * 3/3 = 21/30

It should accept improper fractions (but not decimals and not mixed numbers). We’ve already got code that will spit out the prime factors of a number; I bet it will be useful here.