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)




Comments

Popular posts from this blog

Trouble with the Number System

Residue Arithmetic

Perfect Peak of Array