Created
June 14, 2016 10:05
-
-
Save DonaldKellett/01b3ef4ae5d2561276d2cc30ed4d9c46 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or 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
// ---- | |
// Sass (v3.4.21) | |
// Compass (v1.0.3) | |
// ---- | |
/* | |
Recursion in Sass #2 - Fibonacci | |
(c) Donald Leung. All rights reserved. | |
*/ | |
// Code | |
@function fibonacci($n) { | |
@return if($n == 0, 1, if($n == 1, 1, fibonacci($n - 1) + fibonacci($n - 2))); | |
} | |
// Pseudo-test cases | |
.test-1 { | |
description: "base case 1"; | |
n: 0; | |
expected: 1; | |
actual: fibonacci(0); | |
pass: fibonacci(0) == 1; | |
} | |
.test-2 { | |
description: "base case 2"; | |
n: 1; | |
expected: 1; | |
actual: fibonacci(1); | |
pass: fibonacci(1) == 1; | |
} | |
.test-3 { | |
n: 5; | |
expected: 8; | |
actual: fibonacci(5); | |
pass: fibonacci(5) == 8; | |
} | |
.test-4 { | |
n: 10; | |
expected: 89; | |
actual: fibonacci(10); | |
pass: fibonacci(10) == 89; | |
} |
This file contains hidden or 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
/* | |
Recursion in Sass #2 - Fibonacci | |
(c) Donald Leung. All rights reserved. | |
*/ | |
.test-1 { | |
description: "base case 1"; | |
n: 0; | |
expected: 1; | |
actual: 1; | |
pass: true; | |
} | |
.test-2 { | |
description: "base case 2"; | |
n: 1; | |
expected: 1; | |
actual: 1; | |
pass: true; | |
} | |
.test-3 { | |
n: 5; | |
expected: 8; | |
actual: 8; | |
pass: true; | |
} | |
.test-4 { | |
n: 10; | |
expected: 89; | |
actual: 89; | |
pass: true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment