algos_and_structures/power_of_two/python/negative_power.py
2024-11-02 14:03:30 +03:00

17 lines
No EOL
475 B
Python

def calculate_negative_power_of_two(n: int):
result_array = []
for i in range(1, n):
result_array.append(i)
print(result_array)
for k in range(0, n - 1):
r = 0
print(".", end="")
for i in range(0, k):
r = 10 * r + result_array[i]
result_array[i] = r // 2
r = r % 2
print(result_array[i], end="")
result_array[k] = 5
print("5")
calculate_negative_power_of_two(20)