여기서 기술 단어가 누락되었지만 여기에서 문제는 int를 float 또는 float로 변경하는 것입니다.분해 문제에서 float - int 문제를 설명하십시오.
def factorize(n):
def isPrime(n):
return not [x for x in range(2,int(math.sqrt(n)))
if n%x == 0]
primes = []
candidates = range(2,n+1)
candidate = 2
while not primes and candidate in candidates:
if n%candidate == 0 and isPrime(candidate):
# WHY ERROR?
#I have tried here to add float(), int() but cannot understand why it returns err
primes = primes + [float(candidate)] + float(factorize(n/candidate))
candidate += 1
return primes
ERR - 등 여전히 int()
및 float()
하지만 같은 기능을 수정 시도는 지속 :
float(factorize(n/candidate))
factorize
이 목록을 반환
TypeError: 'float' object cannot be interpreted as an integer
왜 float는'factorize' 함수와 관련이 있습니까? – dan04
dan04 : 그냥 지나치게 살해하십시오. 이제는 작동하지만 여전히 다른 문제에 대해 궁금해하고 있습니다. – hhh