vault backup: 2023-11-23 09:06:47
This commit is contained in:
parent
0f1afcd16a
commit
eee2e1e7c0
@ -54,4 +54,21 @@ def exponetial(x: int, n: int) -> int:
|
|||||||
m *= x
|
m *= x
|
||||||
n -= 1
|
n -= 1
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def power(x, n):
|
||||||
|
if x == 0;
|
||||||
|
if n == 0:
|
||||||
|
raise Exception("0 power 0 undefinded")
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
elif x == 1:
|
||||||
|
return 1
|
||||||
|
elif x == -1:
|
||||||
|
return (n%2)*(-2) + 1
|
||||||
|
else:
|
||||||
|
res = 1
|
||||||
|
while n > 0:
|
||||||
|
res *= x
|
||||||
|
n -= 1
|
||||||
|
return res
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user