Divisor Graph Coloring
Define the divisibility graph G_n on vertex set {1, 2,..., n} where i and j are connected by an edge if one divides the other (and i!= j). Determine the chromatic number chi(G_n).
Problem Statement
This archive keeps the full statement, math, and original media on the page.
For a positive integer \(n\) create a graph using its divisors as vertices. An edge is drawn between two vertices \(a < b\) if their quotient \(b/a\) is prime. The graph can be arranged into levels where vertex \(n\) is at level \(0\) and vertices that are a distance \(k\) from \(n\) are on level \(k\). Define \(g(n)\) to be the maximum number of vertices in a singel level.

The example above shows that \(g(45) = 2\). You are also given \(g(5040) = 12\).
Find the smallest number, \(n\), such that \(g(n) \geq 10^4\).
Problem 881: Divisor Graph Coloring
Mathematical Analysis
Theorem 1 (Chromatic Number)
Proof. The chromatic number equals the length of the longest chain in the divisibility poset.
Upper bound: Assign color where is the 2-adic valuation (largest power of 2 dividing ) … actually this does not work directly. Instead:
Partition into antichains (sets with no divisibility relations). By Dilworth’s theorem, the minimum number of antichains needed equals the length of the longest chain.
Lower bound: The chain has length , and all elements must receive distinct colors.
Upper bound: We exhibit antichains covering . For each , write with odd. Assign color . Two numbers with the same 2-adic valuation are and with odd. If , then , so they can share a chain. This doesn’t immediately give antichains.
Correct approach: The longest chain has length (since ). By Dilworth’s theorem, the minimum number of antichains = longest chain length. This equals since coloring = antichain partition.
Theorem 2 (Dilworth’s Theorem)
In any finite partially ordered set, the maximum size of a chain equals the minimum number of antichains needed to partition the set.
Theorem 3 (Clique Number)
, so the graph is perfect on chains.
Proof. The chain forms a clique of size in . This is maximum since any chain in the divisibility order of has length at most .
Concrete Numerical Examples
: Divisibility Graph
Edges: .
Longest chain: , length 4. So .
Valid 4-coloring: assign color :
- Color 0:
- Color 1:
- Color 2:
- Color 3:
Check: within each color class, no divisibility (e.g., , , etc.).
Verification Table
| Longest chain | |||
|---|---|---|---|
| 1 | 1 | 1 | |
| 2 | 2 | 2 | |
| 4 | 3 | 3 | |
| 8 | 4 | 4 | |
| 10 | 4 | 4 | |
| 16 | 5 | 5 | |
| 100 | 7 | 7 |
Edge Count of
where counts divisors of that are in . Actually:
For : , so .
Complexity Analysis
| Operation | Time |
|---|---|
| Compute | |
| Verify coloring | |
| Count edges | via hyperbola |
Answer
Code
Each problem page includes the exact C++ and Python source files from the local archive.
/*
* Problem 881: Divisor Graph Coloring
* chi(G_n) = floor(log2(n)) + 1 by Dilworth's theorem.
* The longest chain 1, 2, 4, ..., 2^k determines the chromatic number.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int chromatic_number(ll n) {
if (n <= 0) return 0;
int chi = 0;
while ((1LL << chi) <= n) chi++;
return chi;
}
ll edge_count(int n) {
ll total = 0;
for (int k = 1; k <= n; k++)
total += n / k - 1;
return total;
}
bool verify_coloring(int n) {
// color(k) = floor(log2(k))
vector<int> color(n + 1);
for (int k = 1; k <= n; k++) {
int c = 0;
while ((1 << (c + 1)) <= k) c++;
color[k] = c;
}
for (int i = 1; i <= n; i++)
for (int j = 2 * i; j <= n; j += i)
if (color[i] == color[j]) return false;
return true;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout << "=== Chromatic Number ===" << endl;
for (ll n : {1LL,2LL,4LL,8LL,10LL,16LL,100LL,1000LL,(ll)1e9,(ll)1e18}) {
cout << "chi(G_" << n << ") = " << chromatic_number(n) << endl;
}
cout << "\n=== Coloring Verification ===" << endl;
for (int n : {4, 8, 16, 32, 50}) {
bool ok = verify_coloring(n);
cout << "n=" << n << ": " << (ok ? "OK" : "FAIL") << endl;
assert(ok);
}
cout << "\n=== Edge Counts ===" << endl;
for (int n : {10, 50, 100, 500}) {
cout << "|E(G_" << n << ")| = " << edge_count(n) << endl;
}
cout << "\nAnswer: chi(G_{10^18}) = " << chromatic_number((ll)1e18) << endl;
return 0;
}
"""
Problem 881: Divisor Graph Coloring
Chromatic number of divisibility graph G_n on {1,...,n}.
Result: chi(G_n) = floor(log2(n)) + 1 (by Dilworth's theorem).
"""
from math import log2, floor
def chromatic_number(n):
"""chi(G_n) = floor(log2(n)) + 1."""
if n <= 0:
return 0
return floor(log2(n)) + 1
def longest_chain(n):
"""Find the longest divisibility chain in {1,...,n}."""
chain = [1]
while chain[-1] * 2 <= n:
chain.append(chain[-1] * 2)
return chain
def valid_coloring(n):
"""Assign colors: color(k) = floor(log2(k))."""
return {k: floor(log2(k)) for k in range(1, n + 1)}
def verify_coloring(n, coloring):
"""Check that no two adjacent vertices share a color."""
for i in range(1, n + 1):
for j in range(2 * i, n + 1, i):
if coloring[i] == coloring[j]:
return False, (i, j)
return True, None
def edge_count(n):
"""Count edges in G_n: sum_{k=1}^{n} (floor(n/k) - 1)."""
total = 0
for k in range(1, n + 1):
total += n // k - 1
return total
def edge_count_fast(n):
"""O(sqrt(n)) edge count using floor block decomposition."""
# sum floor(n/k) for k=1..n, then subtract n
total = 0
k = 1
while k <= n:
v = n // k
kp = n // v
total += v * (kp - k + 1)
k = kp + 1
return total - n
# --- Verification ---
print("=== Chromatic Number Verification ===")
for n in [1, 2, 3, 4, 5, 8, 10, 16, 32, 64, 100, 1000]:
chi = chromatic_number(n)
chain = longest_chain(n)
coloring = valid_coloring(n)
ok, conflict = verify_coloring(n, coloring)
print(f" n={n:>4}: chi={chi}, chain={chain}, "
f"coloring valid={'OK' if ok else f'FAIL at {conflict}'}")
assert ok
assert len(chain) == chi
print("\n=== Edge Counts ===")
for n in [5, 10, 20, 50, 100]:
e1 = edge_count(n)
e2 = edge_count_fast(n)
print(f" |E(G_{n})| = {e1} (brute), {e2} (fast), Match: {'OK' if e1 == e2 else 'FAIL'}")
assert e1 == e2
print("\n=== Color Classes for n=16 ===")
coloring = valid_coloring(16)
classes = {}
for k, c in coloring.items():
classes.setdefault(c, []).append(k)
for c in sorted(classes):
print(f" Color {c}: {classes[c]}")
answer = chromatic_number(10**18)
print(f"\nAnswer: chi(G_{{10^18}}) = {answer}")
# --- 4-Panel Visualization ---