0

I can't figure out where the jamb is.(Google Translate)

I can't figure out where the jamb is. First comes the working code (Looks for the maximum prime divisor of X), but I don't like the crutch marked # 707. Tried to fix it in 2 code on the line marked # 999, but it throws an error, because of the variable n, which exceeds the maximum index of the ho list. def mdl(x): ho=[] for i in range(x): if x%(i+2)==0: ho.append(i+2) for n in range(x): for i in range(x): if n <= len(ho)-1: #707 if ho[n]%(i+2)==0 and i+2!=ho[n]: ho.remove(ho[n]) print(max(ho)) =================================== def mdl(x): ho=[] for i in range(x): if x%(i+2)==0: ho.append(i+2) for n in range(len(ho)-1): for i in range(x): if ho[n]%(i+2)==0 and i+2!=ho[n]: #999 ho.remove(ho[n]) print(max(ho))

2nd Aug 2020, 9:49 PM
27_07b
27_07b - avatar
2 Réponses
0
(Google translate) I considered this option, but then it seemed to me that the offset in "range" would be compensated by the offset in the number of elements in the "ho" list. I'll think it over carefully. Thanks for the help!
2nd Aug 2020, 11:34 PM
27_07b
27_07b - avatar