OLD | NEW |
1 var html_input_d; | 1 var html_input_d; |
2 (function(exports) { | 2 (function(exports) { |
3 'use strict'; | 3 'use strict'; |
4 // Function fib: (int) → int | 4 // Function fib: (int) → int |
5 function fib(n) { | 5 function fib(n) { |
6 return _fib(n, new core.Map()); | 6 return n === 0 || n === 1 ? 1 : dart.notNull(fib(dart.notNull(n) - 1)) + dar
t.notNull(fib(dart.notNull(n) - 2)); |
7 } | |
8 // Function _fib: (int, Map<int, int>) → int | |
9 function _fib(n, seen) { | |
10 if (n === 0 || n === 1) | |
11 return 1; | |
12 if (seen.get(n) !== null) | |
13 return seen.get(n); | |
14 seen.set(n, dart.notNull(_fib(dart.notNull(n) - 1, seen)) + dart.notNull(_fi
b(dart.notNull(n) - 2, seen))); | |
15 return seen.get(n); | |
16 } | 7 } |
17 // Exports: | 8 // Exports: |
18 exports.fib = fib; | 9 exports.fib = fib; |
19 })(html_input_d || (html_input_d = {})); | 10 })(html_input_d || (html_input_d = {})); |
OLD | NEW |