Parity of two expressions of the same variable

191 Views Asked by At

For example:

Given a variable $n$, and two expressions $n(n-1)/2$ and $n^2 - 1$. If they have the same parity or under what condition, they are all odd, or all even?

I want a general solution which not only applies to these two but all the expressions all of whoese resulting values are integers, to check if two expressions of the same variable have the same parity.

3

There are 3 best solutions below

0
On

I will assume $n$ is an integer.

If $n^2-1$ is even, then $n$ is odd so $n=2k+1$ and thus $${n(n-1)\over 2} = (2k+1)(k+1)$$ so this is also even iff $k+1$ is even, so $k=2l+1$ and thus $n=4l+3$. So both number ar even iff $n\equiv 3\pmod 4$.

Now try your self to figer out when are both odd. (The answer is iff $n\equiv 2\pmod 4$.)

0
On

$n^2-1$ will be even if $n$ is odd

$n=2m+1$(say)

$\dfrac{n(n-1)}2=m(2m+1)$ will be odd or even according as $m$ is

0
On

Check out this link. It's a website which explains parity of expressions.

Even numbers have parity of 0 and odd numbers have parity of 1. Parity of a number is the remainder after dividing by 2.

https://brilliant.org/wiki/modular-arithmetic-parity/