fibonacci sequence
Find this at dartpad.dartlang.org/?source=bbc7c69e-9836-4b31-97e2-f96ebfc977e0.
Created with <3 with dartpad.dartlang.org.
fibonacci sequence
Find this at dartpad.dartlang.org/?source=bbc7c69e-9836-4b31-97e2-f96ebfc977e0.
Created with <3 with dartpad.dartlang.org.
| // fib seq | |
| // 1 1 2 3 5 8 13 21 ... | |
| num fibonacci(num n) { | |
| if (n == 1 || n == 2) { | |
| return 1; | |
| } else { | |
| return fibonacci(n-1) + fibonacci(n-2); | |
| } | |
| } | |
| void main() { | |
| for (num i = 1; i <= 10; i++) { | |
| print(fibonacci(i)); | |
| } | |
| } |