n=1; n=p for a prime p≡1(mod3); and n=p2 for a prime p=3.
Proof
Write g(x)=x2+x+1. The property is: g(d)∣g(n) for every divisor d of n. The divisor d=n gives nothing.
Claim 1.d=1 gives the condition
3∣n2+n+1⟺n≡1(mod3).(1)
Proof. Check the three residues of n modulo 3.
The case n=1 is clear, and if n=p is prime the only conditions are d=1 and d=p, so by (1) the property holds exactly when p≡1(mod3).
Composite n. Let p be the smallest prime factor of n and b=n/p, so that b≥p and every prime factor of b is at least p. We use only the divisor d=b.
Claim 2.g(b)∣g(n) if and only if
(p−1)(pb+p+1)=k(b2+b+1)with an integer k≥1,(2)
and moreover
(p−1)(pb+p+1)=p2b−(pb−p2+1)<p2b.(3)
Proof. The identity
p2b2+pb+1=p2(b2+b+1)−(p−1)(pb+p+1)
shows that g(b)∣g(n) if and only if g(b) divides the positive integer (p−1)(pb+p+1). The inequality (3) holds since b≥p.
Step 1.b is prime.
Proof. If b≥p2, then by (3) the left side of (2) is less than p2b≤b2<g(b), contradicting k≥1. Hence p≤b<p2. As all prime factors of b are at least p, the number b is a prime; call it q.
Step 2.q=p.
Proof. Suppose q>p. From (2), (3) and g(q)>q2 we get k<p2q/q2=p2/q<p, so k≤p−1. Expanding (2),
kq2+kq+k=p2q−pq+p2−1.(4)
Modulo q this gives k≡p2−1. Since k≤p−1<p2−1, there is an integer t≥1 with
p2−1−k=tq.(5)
Substituting p2−1=k+tq into (4) and dividing by q gives kq+k=p2−p+t, that is,
kq=p2−p−k+t.(6)
Subtracting (5) from (6): (k−t)q=t+1−p. By (5), t<p2/q<p, so 2−p≤t+1−p≤0. Thus (k−t)q is a multiple of q lying in the interval (−q,0], hence it is 0. So t=p−1 and k=t=p−1, and (5) becomes (p−1)q=p2−p, i.e. q=p. This contradicts q>p.
Step 3.n=p2 works exactly when p=3.
Proof. So a composite n with the property must be the square of a prime p. Its divisors are 1,p,p2. For d=p,
p4+p2+1=(p2+p+1)(p2−p+1),
so g(p)∣g(p2) always. For d=1, by (1) we need p2≡1(mod3), which holds exactly when p=3.
Together with the cases n=1 and n prime, this proves the answer. ■
Solved it another way? Send a written solution to [email protected]. The most interesting solution, with the solver's name, will be posted.