Created
June 14, 2016 09:47
-
-
Save DonaldKellett/a0adab2eaff8309f6012e6c60e960ff0 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) | |
// ---- | |
/* | |
Sum of first n natural numbers | |
(c) Donald Leung. All rights reserved. | |
*/ | |
// Code | |
@function sum($n) { | |
@return $n * ($n + 1) / 2; | |
} | |
// Pseudo-test cases | |
.test-1 { | |
n: 1; | |
expected: 1; | |
actual: sum(1); | |
pass: sum(1) == 1; | |
} | |
.test-2 { | |
n: 10; | |
expected: 55; | |
actual: sum(10); | |
pass: sum(10) == 55; | |
} | |
.test-3 { | |
n: 100; | |
expected: 5050; | |
actual: sum(100); | |
pass: sum(100) == 5050; | |
} | |
.test-4 { | |
n: 666; | |
expected: 222111; | |
actual: sum(666); | |
pass: sum(666) == 222111; | |
} |
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
/* | |
Sum of first n natural numbers | |
(c) Donald Leung. All rights reserved. | |
*/ | |
.test-1 { | |
n: 1; | |
expected: 1; | |
actual: 1; | |
pass: true; | |
} | |
.test-2 { | |
n: 10; | |
expected: 55; | |
actual: 55; | |
pass: true; | |
} | |
.test-3 { | |
n: 100; | |
expected: 5050; | |
actual: 5050; | |
pass: true; | |
} | |
.test-4 { | |
n: 666; | |
expected: 222111; | |
actual: 222111; | |
pass: true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment