Monday, 30 September 2013

How to format composition functions in python?

How to format composition functions in python?

When I use composition functions Such as Collatz(MerrenianPrime(Number)) I
get the error of:
'Merrenian=2**PrimeCount(Number)-1
TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'NoneType.'
How would I resolve this?
This is my code:
def MerrenianPrime(Number):
Merrenian=2**Prime.PrimeCount(Number)-1 #PrimeCount=nth Prime and this
is where I get an error
if Prime.isPrime(Merrenian)==True: #isPrime function checks primality
of number
print "the prime number",Merrenian,"was found"
else:
print Merrenian,"is not prime."
thanks!

No comments:

Post a Comment