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