Skip to content

Instantly share code, notes, and snippets.

@Tenderfeel
Created October 18, 2012 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tenderfeel/3911497 to your computer and use it in GitHub Desktop.
Save Tenderfeel/3911497 to your computer and use it in GitHub Desktop.
test
//累乗した値を求める
@function pow($a, $b) {
@for $a from 1 through $b {
$a: $a * $a;
}
@return $a;
}
//√nを計算
@function sqrt($n) {
$z: 0;
$k: 0;
@for $j from 0 through 3 {
$m : pow(10, $j);
@for $i from 0 through max(10, $n) {
@if (($z + $i/$m) * ($z + $i/$m)) <= $n {
$k : $i;
}
}
$z: $z + ($k / $m);
}
@return $z;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment