Semilocal commutative ring with two or three maximal ideals Is there any equivalence condition for a commutative ring to have exactly two or three maximal ideals?
 A: I don't know if this could be usefull: I give to you some tricks to compute the number of maximal ideals of some kind of rings.
Consider the Jacobson radical $J(A)$ of a semilocal ring $A$ with maximal ideals $M_1, \dots , M_n$, then
$$ A/J(A) \simeq A/M_1 \oplus \dots \oplus A/{M_n} $$
Now, compute the number of factors of  $$ A/M_1 \oplus \dots \oplus A/M_n$$ is easy by looking at the primitive idempotents (I think there are serveral algorithms that do this, for example looking at the Kernel of the map that sends $x$ to $x^2$).
If $A$ is a finitely generated $k$ algebra, with $k$ algebrically closed, you have just to look at the $rank$ of $A/J(A)$ as $k$-module.
As an easy consequence of this fact, we can easy look at number of factors of a polynomial $p$ of $k[x]$:
If $p=\prod_1^n p_i$ (we can easy reduce to the case of a squarefree polynomial considering $p/GCD(p,p')$) we can consider
$$k[x]/(p) \simeq k[x]/(p_1) \oplus \dots \oplus k[x]/(p_n) $$
and count the number of idempotents in the $k$ algebra above!
For some algorithms to compute idempotents you can look at P.Gianni,V. Miller,B. Trager -  Decomposition of Algebras
Other ways:
If $A$ is a finetely generated $k$-alebra (say $k[x_1, \dots , x_n]/I$), then the number of its maximal ideals is the number of closed points of $V(I)$.
To find the number of this closed points, compute the reduced Grobner base $RG$ of $I$ and count the number of lattice points in the sub-escalier of $RG$.
You can find a better description of this metod in my answer Here
A: The most straightforward characterization that comes to mind is this:

A commutative ring $R$ has only two (resp three, or $n$) maximal ideals iff $R/J(R)$ is isomorphic to the direct product of two (resp three, or $n$) fields. ($J(R)$ denotes the Jacobson radical of $R$.)

I guess you are probably looking for something along the lines of the nice characterization of local rings in terms of elements. I have not heard of a nice counterpart for more maximal ideals, not even the special cases of $2$ or $3$.
There is only one nice theorem I have ever heard regarding rings having exactly two maximal ideals:

The endomorphism ring of a nonzero uniserial right module (one in which the submodules form a chain) has exactly one or exactly two maximal right ideals.

If I recall correctly, one of the ideals is comprised totally of non-surjective endomorphisms, and the other is non-injective endomorphisms (see page 22 for example. It can also be found in Lam's First Course in Noncommutative Rings) It is problematic, of course, to know when these endomorphism rings would be commutative.
