File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ You can compile a file directly via `bsc MyFile.res`:
15
15
let rec fib = n => {
16
16
switch n {
17
17
| 0 | 1 => n
18
- | n => fib(n -1 ) + fib(n- 2 )
18
+ | n => fib(n - 1 ) + fib(n - 2 )
19
19
}
20
20
}
21
21
Js.log(fib(0))
@@ -27,7 +27,7 @@ Js.log(fib(0))
27
27
' use strict' ;
28
28
function fib(n) {
29
29
if (n === 0 || n === 1 ) {
30
- return 1 ;
30
+ return n ;
31
31
} else {
32
32
return fib(n - 1 | 0) + fib(n - 2 | 0) | 0;
33
33
}
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ You can compile a file directly via `bsc MyFile.re` (or `bsc MyFile.ml`):
14
14
// MyFile.re
15
15
let rec fib = n => {
16
16
switch (n) {
17
- | 0 | 1 => 1
18
- | n => fib (n - 1 ) + fib (n - 2 )
17
+ | 0 | 1 => n
18
+ | n => fib (n - 1 ) + fib (n - 2 )
19
19
}
20
20
};
21
21
Js.log(fib(0 ));
@@ -24,7 +24,7 @@ Js.log(fib(0));
24
24
// MyFile.ml
25
25
let rec fib n =
26
26
match n with
27
- | 0 | 1 -> 1
27
+ | 0 | 1 -> n
28
28
| n -> (fib (n - 1)) + (fib (n - 2))
29
29
let _ = Js.log (fib 0)
30
30
```
You can’t perform that action at this time.
0 commit comments