9 Commits

Author SHA1 Message Date
lighting9999
fcf7918374
Update power.py 2025-02-08 18:16:12 +08:00
pre-commit-ci[bot]
9e6c74cd9f [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-02-08 10:02:45 +00:00
lighting9999
bcd0b508c3
Update power.py 2025-02-08 18:02:22 +08:00
pre-commit-ci[bot]
fe3d3d8593 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-02-08 09:56:31 +00:00
lighting9999
456e4fbf3e
Update power.py 2025-02-08 17:56:18 +08:00
pre-commit-ci[bot]
c79cb95ddb [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2025-02-08 09:51:45 +00:00
lighting9999
78adb6463f
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
```
2025-02-08 17:48:46 +08:00
Pedram_Mohajer
70bd06db46
add doctest/document to actual_power and document to power (#11187)
* Update power.py

* Update divide_and_conquer/power.py

---------

Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
2024-06-01 02:09:03 -07:00
AlexLeka98
98733618e2 Added Strassen divide and conquer algorithm to multiply matrices. (#1648)
* Added Strassen divide and conquer algorithm to multiply matrices

* Divide and conquer algorith to calculate pow(a,b) or a raised to the power of b

* Putting docstring inside the function.

* Added doctests
2020-01-12 09:34:10 +05:30