My Blog

My WordPress Blog

Tag: code sample


  • Euclid algorithm for Greatest common Denominator, SML

    fun gcd (x,y) = if y = 0 then x else gcd(y, x mod y) I’ve wondered how to easily do this in code, without having to brute force it.  Turns out Euclid worked out the algorithm over 2,000 years ago. Even if you aren’t a programmer, you can probably follow this code if you…