TITLE: Show that every integer can be written in the form $5a + 7b$ for $a,b \in \mathbb{Z}$
QUESTION [5 upvotes]: Show that every integer can be written in the form $5a + 7b $ for $a,b \in \mathbb{Z}$. HINT: Find, $a_1$ and $b_1$ such that $5a_1 + 7b_1 = 1$.

I have a few questions about this:

How do I gout about finding that $a_1, b_1$? I mean, is there a method I can use, or do I just have to trial and error?
Once I've found this, how does that prove that every integer can be written in the form?

The next question says

Show that ever integer $n \geq 24$ can be written in the form $5a + 7b$ for $a,b \in \mathbb{N}$.

I think I can do this, but the question I have about this one is, if I have something in the form $ax + by$, then how do I know what integers I can write this as? Like, just taking this question as an example, how do you know that it is for all $n \geq 24$ and not any thing less than, or would this by trial and error as well?
EDIT: It took my like 2 seconds to get $a_1 = 3$ and $b_1 = -2$, but if they were bigger or more difficult numbers, would I still use trial and error or is there an actual procedure?

REPLY [3 votes]: I am not sure this has been mentioned in the other answers. Given integers $m, n$, then the numbers that can be represented in the form $m a + n b$, for $a, b$ integers, are the multiples of the gcd $(m, n)$.
It is clear that all numbers $m a + n b$ are multiples of $(m, n)$.
Conversely, let $z = (m, n) t$, with $z, t$ integers. Use Euclid's algorithm to find integers $x, y$ such that $m x + n y = (m, n)$. Now multiply by $t$ to obtain
$$
 z = (m, n) t = m (x t) + n (y t).
$$