Michelle Chan - 4 years ago 175

Python Question

I am doing exercise on Singpath and I am stuck at this question. This question is under recursion exercises but I have no idea what the question means.

A number,, is a power of`a`

if it is`b`

divisible byand`b`

is a power of`a/b`

.`b`

Write a function called`is_power`

that takes parametersand`a`

and`b`

returnsif`True`

is a power of`a`

.`b`

Just thought of the answer and I've posted it below.

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

Here is my answer...

```
def is_power(a,b):
if(a%b != 0):
return False
elif(a/b == 1):
return True
else:
return is_power(a/b,b)
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**