Skip to content

Commit 376cb60

Browse files
committed
Fix: Issue TheAlgorithms#9588
1 parent 95161a0 commit 376cb60

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: maths/base_neg2_conversion.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import doctest
2-
def decimal_to_negative_base_2(n: int) -> int:
2+
def decimal_to_negative_base_2(num: int) -> int:
33
"""
44
This function returns the number negative base 2
55
of the decimal number of the input data.
@@ -20,15 +20,15 @@ def decimal_to_negative_base_2(n: int) -> int:
2020
>>> decimal_to_negative_base_2(7)
2121
11011
2222
"""
23-
if n == 0:
23+
if num == 0:
2424
return 0
2525
ans = ""
26-
while n != 0:
27-
rem = n % -2
28-
n = n // -2
26+
while num != 0:
27+
rem = num % -2
28+
num = num // -2
2929
if rem < 0:
3030
rem += 2
31-
n += 1
31+
num += 1
3232

3333
ans = str(rem) + ans
3434

0 commit comments

Comments
 (0)