Created
August 20, 2025 11:00
-
-
Save mrRedSun/0f204d390c619b16e0a903a90066b444 to your computer and use it in GitHub Desktop.
Tribonacci test
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
import 'dart:async'; | |
void main() async { | |
test(); | |
} | |
void test() { | |
expect(tribonacci(0), 0); | |
expect(tribonacci(1), 1); | |
expect(tribonacci(2), 1); | |
expect(tribonacci(3), 2); | |
expect(tribonacci(4), 4); | |
expect(tribonacci(5), 7); | |
expect(tribonacci(6), 13); | |
expect(tribonacci(7), 24); | |
expect(tribonacci(10), 149); | |
expect(tribonacci(15), 3136); | |
expect(tribonacci(20), 66012); | |
} | |
void expect<T>(T a, T b) { | |
if (a == b) { | |
print('pass'); | |
} else { | |
print('fail. $a != $b'); | |
} | |
} | |
/// The Tribonacci sequence is a series of numbers in which each number (after the first three) | |
/// is the sum of the three preceding ones. | |
/// It starts with 0, 1, 1. The sequence goes: 0, 1, 1, 2, 4, 7, 13, 24, 44, and so forth. | |
int tribonacci(int n) { | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment