Skip to content

Instantly share code, notes, and snippets.

@kmry
Forked from devoncarew/main.dart
Last active January 2, 2019 07:37
Show Gist options
  • Select an option

  • Save kmry/f2d864459bd393b04905d93b21f8594d to your computer and use it in GitHub Desktop.

Select an option

Save kmry/f2d864459bd393b04905d93b21f8594d to your computer and use it in GitHub Desktop.
Fibonacci
//3-1.recursive.
main() {
for (int i = 1; i <= 30; i++) {
print('fibonacci($i) = ${fibonacci(i)}');
}
}
/// Computes the nth Fibonacci number.
int fibonacci(int n) {
return n < 2 ? n : (fibonacci(n - 1) + fibonacci(n - 2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment