Apparently we may have two methods to filter odd an even numbers.
The distinction between them is how they consider number zero 0 case.
Method 1:
n/2 = (q, r) => 2 * q + r = n
For n >= 0:
n is odd, if r > 0
n is even, if r = 0
This method will consider zero 0 to be an even number.
Method 2:
n/2 = (q, r) => 2 * q + r = n
For n >= 0:
n is odd, if q >= 0 and r > 0
n is even, if q > 0 and r = 0n = 0 is neutral, if q = 0 and r = 0
This method will consider zero 0 to have neutral parity, meaning counting neither an odd nor an even number of units 1 corresponding to counted objects present.
Programming Method 1:
while True: a = int(input("a = ")) Aa = abs(a) r = Aa % 2 if r > 0: print(a, "odd") elif r == 0: print(a, "even") else: passOutput:
me@amadeus:~$ python3 Templates/A0a = 33 odda = 22 evena = 11 odda = 00 evena = Programming Method 2:
while not 0: a = int(input("a = ")) Aa = abs(a) q = Aa // 2 r = Aa % 2 # q, r = divmod(Aa, 2) if q >= 0 and r > 0: print(a, "odd") elif q > 0 and r == 0: print(a, "even") elif q == 0 and r == 0: print(a, "neutral") else: passOutput:
me@amadeus:~$ python3 Templates/A1a = 33 odda = 22 evena = 11 odda = 00 neutrala =Addendum:
Therefore, resulting such ironic dialog example.
- Do You have a wife?
- I have an even number of them.
- It is illegal to have an even number of wives.
- I have no choice, because somebody consider "0 is even".
- "I have to live eternal life, and after die, to find, what's love".
I composed this simple poem, because I want to share with You,
🍏☕ and say "Apple and Tea make a Tea+m". 🍒🙃