Last active
November 19, 2024 13:26
-
-
Save mrRedSun/7e704a775c4b34899050990f6302c328 to your computer and use it in GitHub Desktop.
Fibonacci test
This file contains 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
import 'dart:async'; | |
void main() async { | |
test(); | |
} | |
void test() { | |
expect(fibonacci(0), 0); | |
expect(fibonacci(1), 1); | |
expect(fibonacci(2), 1); | |
expect(fibonacci(3), 2); | |
expect(fibonacci(4), 3); | |
expect(fibonacci(50), 12586269025); | |
} | |
void expect<T>(T a, T b) { | |
if (a == b) { | |
print('pass'); | |
} else { | |
print('fail. $a != $b'); | |
} | |
} | |
/// The Fibonacci sequence is a series of numbers in which each number (after the first two) is the sum of the two preceding ones. | |
/// It typically starts with 0 and 1. The sequence goes: 0, 1, 1, 2, 3, 5, 8, 13, 21, and so forth. | |
int fibonacci(int n) { | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment