6. is_prime


Hey guys I have the solution for this problem but I thought a recursion could solve this problem as well. This is what I thought. If I am totally on the wrong track please tell me. Otherwise, I would be curious if it could work out this way as well
def is__prime(c):
if c==2:
return True
elif c<2:
return False
elif c>2:
return False
return True
print is__prime(15)


Your function returns a boolean, do you really want do do c mod <bool> ?

You can implement loops with recursion, but there's nothing to gain in that (especially since python has a preference for being imperative)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.