Answer the question
In order to leave comments, you need to log in
Why are odd divisors displayed along with even divisors?
The program should output 4 even divisors, but it also prints odd divisors (+ does not print the maximum divisor)
for x in range(190201,190280):
sq=int(x**0.5)
d=set()
for i in range(1,sq+1):
if x%i==0 and i%2==0:
d.add(i)
d.add(x//i)
if len(d)==4:
d=sorted(d)
print(d)
Answer the question
In order to leave comments, you need to log in
if someone needs it, then here is another solution
for n in range(190201,190280+1):
a = []
for d in range(1,n+1):
if n % d == 0 and d%2==0:
a.append(d)
if len(a) == 4:
a.reverse()
print(*a)
Replace "if x%i==0 and i%2==0:" with "if x % i == 0 and i % 2== 0 and (x // i) % 2 == 0:"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question