To find all divisors of n, you do not need to check every number from 1 to n. You only need to check from 1 to √n.
Why: if d divides n, then n/d also divides n. These come in pairs. One of them must be ≤ √n, the other ≥ √n.
Example: divisors of 12. Check 1 (gives pair 1, 12), 2 (gives pair 2, 6), 3 (gives pair 3, 4). Stop at √12 ≈ 3.46. Found all divisors: 1, 2, 3, 4, 6, 12.