from math import sqrt def divisors(n): fa={i for i in range(1,int(sqrt(n)) + 1) if not(n%i)} ct={n//i for i in fa} return sorted(fa|ct)
- from math import sqrt
- def divisors(n):
fact = []for i in range(1, int(n**0.5) + 1):if not(n % i):v = n // iif v != i:fact.insert(len(fact)//2,v)fact.insert(len(fact)//2,i)return fact- fa={i for i in range(1,int(sqrt(n)) + 1) if not(n%i)}
- ct={n//i for i in fa}
- return sorted(fa|ct)
being smarter