We first state a well-known lemma
Lemma. (Sylvester's theorem) For two positive integers a and b such that gcd(a,b)=1, the largest integer that could not be written in the form ax+by where x and y are non-negative integers is N0=ab−a−b.
a) Let a be the satisfying value. A natural number n is called 'nice' if there exists x,y,z∈N such that
a2x+6ay+36z=n.
By choosing n=301, we have a2x≡1(mod6) then gcd(a,6)=1, which implies gcd(a,36)=1. Moreover, by applying the Sylvester's theorem for a and 36, the largest number could not be written in the form ax1+36y1 is
36a−a−36=35a−36.
However,
n=a2x+6ay+36z=a(ax+6y)+36z=ax1+36y1,
hence n≥35a−35 which means 250≥35a−35 or a<9. Since gcd(a,6)=1, we conclude a∈{1,5,7}.
* For a=7, the equation becomes n=49x+42y+36z and by putting n=251, we get
251=49x+42y+36z≡z(mod7) hence z≡6(mod7).
This means z≥6. On the other hand, z≤251/36<13 then z=6. The equation becomes 7x+6y=5, which has no natural solution then a=7 is not satisfied.
* For a=1, the equation always has a solution (x,y,z)=(n,0,0).
* For a=5, we have to show that for n≥250, there exists (x,y,z)∈N3 such that
25x+30y+36z=n.
Putting n=5k+r,z=r where r<5 and k≥50, the equation becomes
25x+30y=n−36r=5k−35r⇔5x+6y=k−7r.
However, k−7r≥50−28=22>30−5−6 then by Sylvester's theorem, the equation always has natural solution.
b) We prove a general result: Let a,b be two coprime positive integers. Then
N=a2b+ab2−a2−b2−ab+1
is the smallest positive integer which the equation a2x+aby+b2z=m has natural solution for all m≥N.
* In case m≥N, choosing z=mb−2 (mod a) (0≤z<a) and we need to prove that there exists x,y∈N such that the equation
ax+by=am−b2z
has natural solution. Note that
am−b2z≥aN−b2(a−1)>aa2b−a2−ab=ab−a−b
then the equation always has a natural solution by Sylvester's theorem.
* If m<N, let m=a2b+ab2−a2−b2−ab and assume that there exists a triple (x,y,z)∈N3 such that
a2x+aby+b2z=m
hence a2x≡−a2(modb), b2z≡−b2(moda) which is equivalent to
x≡−1(modb),z≡−1(moda).
Then x≥b−1,z≥a−1 which leads to
y≤abm−a2(b−1)−b2(a−1)=−1.
That is a contradiction since y≥0.
Applying this result, we conclude that the greatest value of n is 5a2+30a−36. □