In an exercise in Atiyah-Macdonald it asks to prove that the prime spectrum $\operatorname{Spec}(A)$ of a commutative ring $A$ as a topological space $X$ (with the Zariski Topology) is compact.
Now because the basic open sets $X_f = \{\mathfrak{p} \in \operatorname{Spec} (A) : \{f\} \not\subseteq \mathfrak{p} \}$ form a basis for the Zariski Topology it suffices to consider the case when
$X = \bigcup_{i \in I} X_{f_i}$
where $I$ is some index set. Then taking the complement on both sides we get that
$\emptyset = \bigcap_{i \in I} X_{f_i}^c$
so there is no prime ideal $\mathfrak{p}$ of $A$ such that all the $f_i$'s are in $\mathfrak{p}$. Now from here I am able to show that the ideal generated by the $f_i$'s is the whole ring as follows. Since there is no prime ideal $\mathfrak{p}$ such that all the $f_i \in \mathfrak{p}$, it is clear that there is no $\mathfrak{p}$ such that $(f_i) \subseteq \mathfrak{p}$ for all $i \in I.$ Taking a sum over all the $i$ then gives $\sum_{i \in I} (f_i) = (1).$
Now here's the problem:
How do I show from here that there is an equation of the form $1 = \sum_{i \in J} f_ig_i,$ where $g_i \in A$ and $J$ some finite subset of $I$?
This part has been giving me a headache. I am not sure if the finiteness bit has to do with algebra, topology or the fact that we are dealing with prime ideals.
This is not a homework problem but rather for self-study.
$\textbf{Edit:}$ I have posted my answer below after the discussion with Dylan and Pierre.