Last active
June 25, 2022 05:39
-
-
Save devoncarew/74e990d984faad26dea0 to your computer and use it in GitHub Desktop.
Fibonacci
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
// 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() { | |
int 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
test