当我使用 Collatz(MerrenianPrime(Number)) 等合成函数时,我收到以下错误:
'Merrenian=2**PrimeCount(Number)-1
TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'NoneType.'
我将如何解决这个问题?
这是我的代码:
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."
谢谢!