0% found this document useful (0 votes)
38 views1 page

Programming Assignment 4

Uploaded by

asdsafsvvsg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views1 page

Programming Assignment 4

Uploaded by

asdsafsvvsg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

def is_power(a, b):

# Checks whether a is a power of b.


print a, b
if a == b:
print 'a is a power of b'
return True
elif a % b == 0:
is_power(a/b, b)
else:
return False

It does. If I do
print is_power(4, 2),
it prints:

4 2
2 2
a is a power of b
None

You might also like