Find the even odd using bitwise
We can use bitwise And to check even or odd
if n is a number then
n&1 result the 1
else result the 0
def oddeven(n):
if n&1==1:
print("ODD")
else:
print("EVEN")
n=int(input())
oddeven(n)
We can use bitwise And to check even or odd
if n is a number then
n&1 result the 1
else result the 0
def oddeven(n):
if n&1==1:
print("ODD")
else:
print("EVEN")
n=int(input())
oddeven(n)
Comments
Post a Comment