Skip to content

Instantly share code, notes, and snippets.

@chriseppstein
Created August 5, 2011 21:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriseppstein/1128581 to your computer and use it in GitHub Desktop.
Save chriseppstein/1128581 to your computer and use it in GitHub Desktop.
Generate the factors of a number.
// 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;
}
@igbanam
Copy link

igbanam commented Aug 6, 2011

Why do this in SASS? Please give an example where one could use this.

@scottkellum
Copy link

@igbanam math homework.

Other than that I am sure someone can find a uses with page geometry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment