Python/divide_and_conquer
lighting9999 338cbafe0d
Improve power.py (#12567)
* Fix And Add power.py

To fix the inaccuracies and allow handling of negative exponents and bases, the key issue lies in how negative numbers are handled in the power calculation, especially when dividing.
## Example Output:
```python
>>> power(4, 6)
4096
>>> power(2, 3)
8
>>> power(-2, 3)
-8
>>> power(2, -3)
0.125
>>> power(-2, -3)
-0.125
```

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update power.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update power.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update power.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update power.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
2025-02-09 20:51:18 +03:00
..
__init__.py Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
closest_pair_of_points.py Fix ruff (#11527) 2024-08-25 17:33:11 +02:00
convex_hull.py Enable ruff PLR5501 rule (#11332) 2024-03-28 18:25:41 +01:00
heaps_algorithm_iterative.py Heaps algorithm iterative (#2505) 2020-09-29 12:38:12 +02:00
heaps_algorithm.py Heaps algorithm (#2475) 2020-09-29 12:39:07 +02:00
inversions.py Add pep8-naming to pre-commit hooks and fixes incorrect naming conventions (#7062) 2022-10-13 00:54:20 +02:00
kth_order_statistic.py [pre-commit.ci] pre-commit autoupdate (#11322) 2024-03-13 07:52:41 +01:00
max_difference_pair.py [mypy] fix small folders (#4292) 2021-03-23 16:51:50 +01:00
max_subarray.py [pre-commit.ci] pre-commit autoupdate (#11322) 2024-03-13 07:52:41 +01:00
mergesort.py Pyupgrade to Python 3.9 (#4718) 2021-09-07 13:37:03 +02:00
peak.py [pre-commit.ci] pre-commit autoupdate (#11322) 2024-03-13 07:52:41 +01:00
power.py Improve power.py (#12567) 2025-02-09 20:51:18 +03:00
strassen_matrix_multiplication.py Mention square matrices in strassen docs and make it more clear (#9839) 2023-10-07 05:35:23 -04:00