← Back to Games

💎 Divisor Dungeon

Find all factors of N and collect gems for each pair!

🏰 The Number
36
√N = 6 (checking up to this)
💎
0
Factors Found
🔍 Factor Pairs
For each i that divides N, we get factor pair (i, N/i)

📚 Efficient Factor Counting

To find all factors of N, we only need to check from 1 to √N!

for i = 1 to √N:
  if N % i == 0:
    factors.add(i) // Found factor i
    if i != N/i:
      factors.add(N/i) // Found factor N/i

Why √N? If i divides N, then N/i also divides N. One of them must be ≤ √N!
Time Complexity: O(√N) instead of O(N)