# Thread: What equation (sequence) would resolve any number into either odd or even?

1. Entry Level Fresher
Join Date
Jun 2007
Posts
1

## What equation (sequence) would resolve any number into either odd or even?

Hello all,I'm having trouble trying to figure out an equation that will categorize any number to either zero (for even numbers) and one (for odd numbers). For example:0 = 0 (even)1 = 1 (odd)2 = 0 (even)3 = 1 (odd)4 = 0 (even)5 = 1 (odd)6 = 0 (even)7 = 1 (odd)Any help would be much appreciated. Thanks!

2. Entry Level Fresher
Join Date
Jun 2007
Posts
1
Well the typical way is to define a function that has two possible values. i.e.f(x) = 0 (for all x even)f(x) = 1 (for all x odd)This is a perfectly valid function.

3. Entry Level Fresher
Join Date
Jun 2007
Posts
1
well if you take the square root of the even or odd number than the even number will be a whole number or irrational number if you know what i am saying you would know.

4. Entry Level Fresher
Join Date
Jun 2007
Posts
1
The sequence a_n = (1 - (-1)^n)/2 does the job. Just check

5. Entry Level Fresher
Join Date
Jun 2007
Posts
3
With the exception of zero, X-(X+1) would work. Zero would end up being odd even though it is neither odd nor even.

6. Entry Level Fresher
Join Date
Jun 2007
Posts
1
n is even if and only if (-1)^n = 1 help, or no?