You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
489 B
Dart
20 lines
489 B
Dart
10 years ago
|
// Go ahead and modify this example.
|
||
|
|
||
|
import "dart:html";
|
||
|
|
||
|
// Computes the nth Fibonacci number.
|
||
|
int fibonacci(int n) {
|
||
|
if (n < 2) return n;
|
||
|
return fibonacci(n - 1) + fibonacci(n - 2);
|
||
|
}
|
||
|
|
||
|
// Displays a Fibonacci number.
|
||
|
void main() {
|
||
|
int i = 20;
|
||
|
String message = "fibonacci($i) = ${fibonacci(i)}";
|
||
|
|
||
|
// This example uses HTML to display the result and it will appear
|
||
|
// in a nested HTML frame (an iframe).
|
||
|
document.body.append(new HeadingElement.h1()..appendText(message));
|
||
|
}
|