I am trying to solve the inequality $a + b <2021$, where $1\leqslant a \leqslant 2023$ and $1\leqslant b \leqslant 2023$, $a$ and $b$ are integer numbers, $a \neq b$. I tried
- with $a = 1$, then $b\in \{2, 3, \ldots, 2019\}$, there are 2018 numbers.
- with $a = 2$, then $b\in \{1, 3, 4, \ldots, 2018\}$ , there are 2017 numbers.
- $a = 2019$, then $b=1$.
Thus, I have $1 + 2 + 3 + \cdots + 2018=2037171$
Your answer is short by $1009$. First I show how your solution can be proven wrong easily, and then I show how to find the correct solution:
You write the no. of values $b$ can take when $a=1$, $a =2$, .... $a = 2019$, and you add them up. You say it's equal to $1+2+3...+2018$. However, initially, you added $2019$ numbers, but now you're adding only $2018$ numbers. So, there is a mistake in your answer.
$$a+b < 2021$$$$b<2021-a$$Since $a,b \in \Bbb Z$ $$b \le 2020-a$$ We also know $b \ge 1$. So, $b$ can take all values from $1$ to $2020-a$ except $a$ if $a \le 1010$. However, if $a \ge 1011$, then $b$ can take all values from $1$ to $2020-a$ (since $a = b$ is not possible here). So, for $a$ from $1$ to $1010$, you have $2019-a$ values for $b$ and for $a$ from $1011$ to $2019$, you have $2020-a$ values for $b$. Thus, the total number of solutions: $$(2018+2017+...+1010+\color{green}{1009)+(1009}+1008+...+2+1) = \boxed{2038180}$$
Slightly easier approach:
Forget that you have $a \neq b$. Then, like the solution above, you get $1 \le b \le 2020-a$. As $a$ goes from $1$ to $2019$, no. of values for $b$ goes from $2019$ to $1$. Hence, you have $2019+2018+...+2+1 = 2039190$ solutions without the constraint $a \neq b$. You will have exactly $1010$ solutions where $a = b$, which correspond to the ordered pairs $(a,b)$ : $(1,1),(2,2),...,(1009,1009), (1010,1010)$. Subtract $1010$ to get the final answer $$2039190 - 1010 = \boxed{2038180}$$