TITLE: Determine the Set of a Sum of Numbers
QUESTION [10 upvotes]: I want to determine the set of natural numbers that can be expressed as the sum of some non-negative number of 3s and 5s.
$$S=\{3k+5j∣k,j∈\mathbb{N}∪\{0\}\}$$
I want to check whether that would be:
0,3, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, and so on.
Meaning that it would include 0, 3, 5, 8. Then from 9 and on, every Natural Number. But how would I explain it as a set? or prove that these are the numbers in the set?

REPLY [10 votes]: This doesn't tell you exactly which numbers can be written as $3k+5j$ with $j,k\ge0$, but it might be the best that can be said in general. These are two Theorems that usually accompany Bezout's Identity.

Theorem $\boldsymbol{1}$: Suppose $\operatorname{gcd}(a,b)=1$ and $c \ge (a-1)(b-1)$.  Then $ax+by=c$ has a non-negative solution, that is, one in which both $x$ and $y$ are
non-negative integers.
Proof of Theorem $\boldsymbol{1}$:
Since $gcd(a,b)=1$, we have some $(u,v)$ so that $au+bv=1$.  The set of all
solutions to $ax+by=c$ is $\{ (cu+bk,cv-ak) : k \in Z \}$.  Thus, we have a
non-negative solution $(x,y)$, i.e. one in which both $x$ and $y$ are non-
negative, precisely when there is an integer $k$ so that $k \ge -cu/b$ (so
that $cu+bk \ge 0$) and $k \le cv/a$ (so that $cv-ak \ge 0$).  Thus, $ax+by=c$
has a non-negative iff there is an integer in $[-cu/b,cv/a]$.
Suppose there is no integer in this interval.  This means that it must
be contained in some interval $(j,j+1)$.  Since $cu$ and $cv$ are integers,
we must have
$$
    -cu/b-j \ge 1/b\tag{1a}
$$
and
$$
    j+1-cv/a \ge 1/a\tag{1b}
$$
Adding $(1a)$ and $(1b)$ and multiplying by $ab$ gives
$$
    ab-cau-cbv \ge a+b\tag{1c}
$$
Since $au+bv=1$, $(1c)$ becomes
$$
    c \le ab-a-b\tag{1d}
$$
Therefore, if $c \ge ab-a-b+1 = (a-1)(b-1)$, then there is a non-negative
solution $(x,y)$ to $ax+by=c$.
$$\square$$

Theorem $\boldsymbol{2}$: Suppose $\operatorname{gcd}(a,b)=1$, $0 \lt c \lt ab$, and neither $a\mid c$ nor $b\mid c$.  Then
one and only one of
$$
    ax+by=c\tag{2a}
$$
and
$$
    ax+by=ab-c\tag{2b}
$$
has a non-negative solution.
Proof of Theorem $\boldsymbol{2}$:
Note that since neither $a\mid c$ nor $b\mid c$, neither $x$ nor $y$ can be $0$ in any solution.  Therefore, any non-negative solution must be a positive
solution, that is, one in which both $x$ and $y$ are positive integers.
Suppose both $as+bt=c$ and $au+bv=ab-c$ are positive solutions.  Add them
together to get
$$
    a(s+u)+b(t+v) = ab\tag{2c}
$$
Since $gcd(a,b)=1$, $(2c)$ says that $b|s+u$ and $a|t+v$.  Since $s$, $t$, $u$, and $v$ are positive integers, we must have that $s+u\ge b$ and $t+v\ge a$.  However, then $a(s+u)+b(t+v) \ge 2ab$, which contradicts $(2c)$.
Therefore, we have shown that at most one of $(2a)$ and $(2b)$ can have a
non-negative solution.
Suppose $(2a)$ does not have a non-negative solution.  Since $gcd(a,b)=1$,
we have some $(u,v)$ so that $au+bv=1$.  The set of all solutions to $ax+by=c$
is then $\{ (cu+bk,cv-ak) : k \in Z \}$.  Therefore, we can find an $(s,t)$ so
that $as+bt=c$ and $0 \le s \lt b$.
Since $bt = c-as$, we have that $-ab \lt bt \lt ab$.  Since $(2a)$ does not have
a non-negative solution, we must have $-ab \lt bt \lt 0$.  Thus, we have the
non-negative solution $a(b-s)+b(-t) = ab-c$.
Therefore, we have shown that at least one of $(2a)$ and $(2b)$ must have a
non-negative solution.
$$\square$$