generateFibonacci function

List<int> generateFibonacci(
  1. int n
)

Implementation

List<int> generateFibonacci(int n) {
  List<int> fib = [0, 1];
  for (int i = 2; i < n; i++) {
    fib.add(fib[i - 1] + fib[i - 2]);
  }
  return fib;
}