Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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));
- }
Add Comment
Please, Sign In to add comment