Skip to content

Instantly share code, notes, and snippets.

@alexgetty
Last active January 4, 2016 09:29
Show Gist options
  • Save alexgetty/8602586 to your computer and use it in GitHub Desktop.
Save alexgetty/8602586 to your computer and use it in GitHub Desktop.
Find the Nth value of the Fibonacci Sequence in Sass. Exponent function by Scott Kellum (gist.github.com/scottkellum/1160816)
@function exponent($base, $exponent) {
$value: $base;
@if ($exponent > 1) {
@for $i from 2 through $exponent {
$value: $value * $base;
}
}
@if ($exponent < 1){
@for $i from 0 through -$exponent{
$value: $value / $base;
}
}
@return ($value)
};
@function fibonacci($n) {
$val: (exponent($_Phi, $n) - exponent(-$_phi, $n)) / ($_Phi - (-$_phi));
@return $val;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment