Files
sdk/pkg/front_end/testcases/fibonacci.dart
T

15 lines
385 B
Dart

// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
int fibonacci(int n) {
if (n < 2) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
main() {
for (int i = 0; i < 20; i++) {
print(fibonacci(i));
}
}