0

Is this statement true? Statement: "All the natural numbers except 1 can be expressed in the form of $2x + 3y$"

NOTE: $x$ and $y$ should be non-negative

If yes then can you show how to prove this?

Context: There is a programming question, solution of which can be optimized using this property.

Problem statement:

You are given a $0$-indexed integer array tasks, where tasks[i] represents the difficulty level of a task. In each round, you can complete either $2$ or $3$ tasks of the same difficulty level. Return the minimum rounds required to complete all the tasks, or $-1$ if it is not possible to complete all the tasks.

Solution which uses this property.

Bill Dubuque
  • 272,048

3 Answers3

3

Let $n$ be a natural number and $n>1$. There are two possibilitites, $n$ is even or $n$ is odd. If $n$ is even then $n=2x$ for some integer $x$. If $n$ is odd then $n\geq 3$, and so $(n-3)$ is a non-negative integer which is even, therefore $(n-3) = 2x$ and so $n = 2x + 3$. Regardless of what $n$ is we can see we can always express $n$ in the form $2x+3y$ where $x\geq 0$ and $y\geq 0$ (in fact, with the stronger requirement that $y=0$ or $y=1$).

  • You need to show that $1$ cannot be expressed is said form. – copper.hat Jan 04 '23 at 04:46
  • @copper.hat Technically not true, as far as the statement "all natural numbers except $1$ can be represented in this form" goes, whether $1$ actually also can be represented in that form is irrelevant. If $1$ were expressible in that form (which it quite clearly isn't) then it would still be true anyway that all other natural numbers are expressible in that form. – Stephen Donovan Jan 04 '23 at 04:48
  • Depends on how you interpret the statement. – copper.hat Jan 04 '23 at 04:50
  • @copper.hat I still hold that as written it would be irrelevant, but in any case you can prove $1$ isn't representable very easily as follows: suppose $2x + 3y = 1$ for some nonnegative integers $x$ and $y.$ $1$ is not divisible by $2$ or $3,$ so $x \neq 0$ and $y \neq 0.$ So, $x \geq 1$ and $y \geq 1,$ but this implies $2x \geq 2$ and $3y \geq 3,$ so $1 = 2x + 3y \geq 5,$ causing a contradiction. Therefore, the supposed representation does not exist. – Stephen Donovan Jan 04 '23 at 04:53
  • @StephenDonovan Yes, I proved that in a comment above. – copper.hat Jan 04 '23 at 04:56
  • My apologies, I didn't see that. – Stephen Donovan Jan 04 '23 at 04:57
  • Please strive not to post more (dupe) answers to dupes of FAQs, cf. recent site policy announcement here. – Bill Dubuque Jan 04 '23 at 07:43
1

Assuming we take $x$ and $y$ to be non-negative integers, we can proceed quite directly.

Let $n$ represent an arbitrary natural number we'd like to represent in this fashion. The case where $n$ is even works out rather immediately, since if $n$ is even then $n = 2k$ for some positive integer $k,$ so let $x = k, y = 0$ and $2(k) + 3(0) = 2k = n.$

If $n$ is odd, then $n = 2k + 1$ for some integer $k,$ and $n \geq 3$ implies $k \geq 1.$ We know the odd $1$ left over has to come from a $3,$ so we can rearrange our form for $n$ into $n = 2k + (- 2 + 2) + 1 = (2k - 2) + 3 = 2(k-1) + 3(1),$ and because $k \geq 1$ we have $k - 1 \geq 0,$ so $x = k - 1, y = 1$ gives us nonnegative solutions for $x$ and $y.$

Now because all natural numbers are either even or odd, and the only restriction on our natural value $n$ was that it was greater than $1,$ this concludes the proof that all natural numbers greater than $1$ can be represented in this form.

However, this does not guarantee that the breakdowns given in this proof are optimal. For instance, these procedures would break $n = 6$ into three twos, when it's rather clear the optimal grouping would be two threes. In general, we should be able to see that the smallest combined value for $x$ and $y$ comes from when we maximize the number of $3$s used, instead of $2$s as we are in our procedure. We can adjust for this by simply shifting from letting the number of $3$s determine the remainder mod $2,$ we can let the $2$s determine the remainder mod $3,$ and fill the rest with as many $3$s as possible.

In case this is a homework problem I'll hold off from undergoing this process myself for now, but I would suggest carrying out the analogue of the odd-even argument with the remainders of $0, 1,$ and $2$ mod $3$ instead. This will give you representations which maximize $y,$ which I claim would minimize $x + y,$ the total number of rounds. (leaving out the proof for now for the sake of time)

1

Thanks everyone for the amazing proofs!

For the optimization part we have to see number in the form of mod $3$ and not in mod $2$.

We can see that to optimize our solution we need to use $3$ as many times as possible and the remaning part will be made up using the $2$.

So instead of bifurcating the number as even and odd which is in the form of mod $2$ ($2k$ or $2k + 1$) we will represent our number in the form of $3K$ or $3K + 1$ or $3K + 2$.

Cases:

  • $n = 3K$ we need only $K$ operations and this will by default be the minimum number of operations required
  • $n = 3K + 1$ we will reframe this as $3(k - 1) + 3 + 1 = 3(K - 1) + 2 + 2$ which means we require $K + 1$ operations ($K - 1$ operations for using $3$ and $2$ operations for using $2$).
  • $n = 3K + 2$ this also means we need $K + 1$ operations ($K$ times for $3$ and $1$ time for using $2$).
  • 1
    This looks correct to me, great job. For the sake of coding this into your solution, it's worth noting that in all of these cases $k$ is the result of the integer division $n / 3$ in most languages. (also, if you want to prove the optimality more rigorously, it mainly comes down to an algebra exercise: if $2x_0 + 3y_0 = 2x_1 + 3y_1$ and $y_0 > y_1,$ it should be easy to show that $x_0 + y_0 < x_1 + y_1,$ if you would like to) – Stephen Donovan Jan 04 '23 at 05:33
  • Please strive not to post more (dupe) answers to dupes of FAQs, cf. recent site policy announcement here. – Bill Dubuque Jan 04 '23 at 07:43
  • @StephenDonovan I tried to prove this statement if $2x_1 + 3y_1 = 2x_2 + 3y_2$ and $y_1 > y_2$ then show that $x_1 + y_1 < x_2 + y_2$, but I can only prove $x_1 < x_2$ but not $x_1 + y_1 < x_2 + y_2$ I don't know how to bring $y_1$ and $y_2$ in that inequality. – Piyush Keshari Jan 04 '23 at 09:21
  • @PiyushKeshari $x_1 < x_2$ is a good stepping stone, now consider that because the two sides of our original equation $2x_1 + 3y_1 = 2x_2 + 3y_2$ are equal, we can add each side to either side of our inequality $x_1 < x_2,$ yielding $3x_1 + 3y_1 < 3x_2 + 3y_2,$ so dividing both sides by $3$ yields our objective – Stephen Donovan Jan 04 '23 at 10:00