I want to know, how to calculate the number of integral solutions of $x+2y=n$.
Asked
Active
Viewed 314 times
-2
-
1Are you restricting $x,y,n$ to be positive integers? Or non-negative integers? If they are unrestricted, then there are infinitely many solutions. – almagest Jan 17 '20 at 08:15
-
Yes , x and y are restricted to be only positive. – Tomato Master Jan 17 '20 at 09:48
-
1Then it is easy, there is one solution for each of $y=1,2,\dots,\lfloor\frac{n}{2}\rfloor$ or $\lfloor[\frac{n}{2}\rfloor$ in total. [Note that $\lfloor\frac{n}{2}\rfloor=n/2$ if $n$ is even and $(n-1)/2$ if $n$ is odd.] – almagest Jan 17 '20 at 09:55
1 Answers
0
Assuming that you want positive integr solutions of $x+2y=n$ is $y=1, x=n-2$ Check that $x=n-2+2m, y=1-m$ then the condition that $x,y > 0$ implies that $-[(n-2)/2] < m < 1$, [.] denotes the integer part total number os solutions are $n/2-1$ if $n$ is even or $(n-1)/2$.
Z Ahmed
- 43,235
-
@DrZatarAhmedDSc $x,y$ are restricted to be positive, not non-negative – almagest Jan 17 '20 at 09:51
-