Last active
March 4, 2019 06:42
-
-
Save terkel/6ec73cee2f425e9ca15376916e231ad0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reduce a fraction | |
// @param {Number} $a | |
// @param {Number} $b | |
// @returns {Array} - A reduced fraction | |
@function frac-reduce ($a, $b) { | |
$gcd: gcd($a, $b); | |
@return $a / $gcd, $b / $gcd; | |
} | |
// Find the greatest common divisor | |
// @param {Number} $a | |
// @param {Number} $b | |
// @returns {Number} - The greatest common divisor | |
@function gcd ($a, $b) { | |
@return if($b == 0, $a, gcd($b, $a % $b)); | |
} | |
// Find the least common multiple | |
// @param {Number} $a | |
// @param {Number} $b | |
// @returns {Number} - The least common multiple | |
@function lcm ($a, $b) { | |
@return $a * $b / gcd($a, $b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment