File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -32,9 +32,9 @@ const FibonacciRecursive = (number) => {
32
32
case number :
33
33
return list
34
34
default :
35
- const sign = number < 0
35
+ const sgn = number < 0
36
36
list . push (
37
- sign ?
37
+ sgn ?
38
38
list . at ( - 2 ) - list . at ( - 1 )
39
39
:
40
40
list . at ( - 1 ) + list . at ( - 2 )
@@ -47,16 +47,16 @@ const FibonacciRecursive = (number) => {
47
47
const dict = new Map ( )
48
48
49
49
const FibonacciRecursiveDP = ( stairs ) => {
50
- const sign = stairs < 0
51
- if ( sign ) stairs *= - 1
50
+ const sgn = stairs < 0
51
+ if ( sgn ) stairs *= - 1
52
52
53
53
if ( stairs === 0 ) return 0
54
54
if ( stairs === 1 ) return 1
55
55
56
56
// Memoize stair count
57
57
if ( dict . has ( stairs ) ) return dict . get ( stairs )
58
58
59
- const res = sign
59
+ const res = sgn
60
60
? FibonacciRecursiveDP ( stairs - 2 ) - FibonacciRecursiveDP ( stairs - 1 )
61
61
: FibonacciRecursiveDP ( stairs - 1 ) + FibonacciRecursiveDP ( stairs - 2 )
62
62
@@ -171,8 +171,8 @@ const FibonacciMatrixExpo = (n) => {
171
171
172
172
if ( n === 0 || n === 0n ) return n
173
173
174
- const sign = n < 0
175
- if ( sign ) n = - n
174
+ const sgn = n < 0
175
+ if ( sgn ) n = - n
176
176
177
177
const isBigInt = typeof n === 'bigint'
178
178
const ZERO = isBigInt ? 0n : 0
@@ -189,7 +189,7 @@ const FibonacciMatrixExpo = (n) => {
189
189
[ ZERO ]
190
190
]
191
191
F = matrixMultiply ( poweredA , F )
192
- return F [ 0 ] [ 0 ] * ( sign ? ( - ONE ) ** ( n + ONE ) : ONE )
192
+ return F [ 0 ] [ 0 ] * ( sgn ? ( - ONE ) ** ( n + ONE ) : ONE )
193
193
}
194
194
195
195
export { FibonacciDpWithoutRecursion }
You can’t perform that action at this time.
0 commit comments