Skip to content

Instantly share code, notes, and snippets.

@scottkellum
Created August 21, 2011 16:29
Show Gist options
  • Save scottkellum/1160816 to your computer and use it in GitHub Desktop.
Save scottkellum/1160816 to your computer and use it in GitHub Desktop.
Sassy exponents
// Sass exponent support
@function exponent($base, $exponent)
// reset value
$value: $base
// positive intergers get multiplied
@if $exponent > 1
@for $i from 2 through $exponent
$value: $value * $base
// negitive intergers get divided. A number divided by itself is 1
@if $exponent < 1
@for $i from 0 through -$exponent
$value: $value / $base
// return the last value written
@return ($value)
@alexgetty
Copy link

This is great. I've used your exponent function in a recent gist of mine to calculate the fibonacci sequence and I wanted to thank you. https://gist.github.com/AlexGetty/8602586

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