The above URL links to properly formatted code in the computer language used in the Litvins' text.
GCD(a,b) is computed using Euclid's Method, taken up by Knuth as probably one of the most important algorithms of all time.
If a K16 curriculum does not mention Euclid's Method say by grade 10, it's likely not worth the trees that were mowed to truck it to your state.
If you're a parent with a pitch fork, flip to the index and take a look. If Euclid's Method is not in Common Core Standards, write to your state representative and think about finding a more serious school perhaps based overseas in a less backward nation.
Typical of the 1900s was to factor both a and b into unique primes using the "factor tree" method and then taking the product of all primes in common as the GCD. This method does not scale well as it requires a complete factorization, which is both time consuming and impractical in many cases.
Assume rational number p/q is represented as Q(p, q).
Also, we know:
LCM(a,b) = (a*b)/GCD(a,b) # Knuth, using greatest common divisor derived by Euclid's Method
So if adding Q(m, n) + Q(a, b) you may choose to go:
LCM(n, b) = c # to get a common denominator (lowest common multiple)
k = c/n is how many times n goes into c (no remainder) so (m/n)(k/k) = (mk)/(nk) = (mk)/c j = c/b is how many times b goes into c (no remainder) so (a/b)(j/j) = (aj)/(bj) = (aj)/c
Q(m, n) + Q(a, b) = Q(mk, c) + Q(aj, c) where c = LCM(n, b) and k = c/n, j = c/b
Another approach is to not go for the LCM at all but the simply multiply the denominators together and get lowest terms at the end.
Neither of these techniques is at all new in terms of algorithm, but have a state of the art industrial strength computer language to cast it in gives the student a working virtual machine that actually does the tedious work.
So once the algorithm is understood algebraically and exercised a few times manually, the drudgery of actually doing the computations can be shifted onto the machine's shoulders.
Much more elaborate computations using Q may be then undertaken, including the leap to continued fractions, which 1900 K12 texts, devoid of computing, tended to eschew.
We're having an Education Summit at Pycon in 2013 (registration already open) where I hope to represent my school.
This building was recently used to stage a teach in regarding the Bucky Fuller syllabus, using film and live music. The film showed the Stanford Archives (where the Chronofile is kept) and went over many of the inventions and designs, including the T.C. Howard laser dome at Seattle Center, originally a Boeing exhibit for the Seattle Worlds Fair in the 1960s (I went to that, must have been about 4 years old at the time).
Washington High School is where Linus Pauling went to school and is a nominal headquarters for our STEM faculty (some of us actually meet at Pauling's boyhood home, not at the school, which is boarded up, usually, except when it becomes a site for art colony events).