dart.dart 489 B

12345678910111213141516171819
  1. // Go ahead and modify this example.
  2. import "dart:html";
  3. // Computes the nth Fibonacci number.
  4. int fibonacci(int n) {
  5. if (n < 2) return n;
  6. return fibonacci(n - 1) + fibonacci(n - 2);
  7. }
  8. // Displays a Fibonacci number.
  9. void main() {
  10. int i = 20;
  11. String message = "fibonacci($i) = ${fibonacci(i)}";
  12. // This example uses HTML to display the result and it will appear
  13. // in a nested HTML frame (an iframe).
  14. document.body.append(new HeadingElement.h1()..appendText(message));
  15. }