Created
August 5, 2011 21:39
-
-
Save chriseppstein/1128581 to your computer and use it in GitHub Desktop.
Generate the factors of a number.
This file contains 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
// Generate the factors of $n | |
// factors(24) #=> 1 2 3 4 6 8 12 24 | |
@function factors($n) { | |
$factors: (); | |
@for $i from 1 through $n { | |
@if $n % $i == 0 { | |
$factors: append($factors, $i) | |
} | |
} | |
@return $factors; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why do this in SASS? Please give an example where one could use this.