Search
 
SCRIPT & CODE EXAMPLE
 

DART

fibonacci numbers in dart

import 'dart:io';

void main() {
  stdout.write("How many Fibonacci numbers do you want? ");
  int chosenNumber = int.parse(stdin.readLineSync());

  List<int> result = fibonacciNumbers(chosenNumber);
  print(result);
}

// Function to calulcate the Fibonacci numbers
List<int> fibonacciNumbers(int chosenNumber) {
  List<int> fibList = [1, 1];

  for (var i = 0; i < chosenNumber; i++) {
    fibList.add(fibList[i] + fibList[i + 1]);
  }
  return fibList;
}
Comment

PREVIOUS NEXT
Code Example
Dart :: Bad state: Stream has already been listened to 
Dart :: flutter make a container clickable 
Dart :: dispose in flutter widget 
Dart :: android studio avd crashing 
Dart :: dart list sort by value with custom class 
Dart :: Flutter Dart - Difference Two DateTime 
Dart :: dart create singleton with parameters 
Dart :: how to remove leading in flutter 
Dart :: flutter remove appbar leading padding 
Dart :: flutter snackbar action button text color 
Dart :: if then else inside child in flutter 
Dart :: flutter sliverappbar 
Dart :: fluter check that date is greater than another date 
Dart :: dart list generate 
Dart :: routes in flutter 
Dart :: leading in flutter(drawer) 
Dart :: how to put two trailing icons in list tile flutter 
Dart :: flutter showdialog barrierdismissible 
Dart :: dart contains method 
Dart :: flutter floor database command 
Dart :: AnimatedCrossFade 
Dart :: global navigator key flutter 
Dart :: dart define value null 
Dart :: flutter increment decrement widget 
Dart :: flutter multi icon button 
Dart :: Flutter find if offset inside a polygon 
Dart :: how to check if val only spaces in dart 
Dart :: dart initialize array 
Dart :: how to group data by date in a listview in flutter 
Swift :: firebase crashlytics dsym missing 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =