Skip to content

Instantly share code, notes, and snippets.

@jcollins-g
Forked from devoncarew/main.dart
Created October 19, 2018 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcollins-g/7d78af42d7b0aedfd92f00899f93561b to your computer and use it in GitHub Desktop.
Save jcollins-g/7d78af42d7b0aedfd92f00899f93561b to your computer and use it in GitHub Desktop.
Fibonacci
// Copyright 2015 the Dart project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file.
void main() {
var i = 20;
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