Skip to content

Commit

Permalink
solve odd or even problem in python using AND bitwise operator
Browse files Browse the repository at this point in the history
  • Loading branch information
justanindieguy committed Jan 18, 2023
1 parent c7f6eec commit 4aae894
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Bit-manipulationTechniques/OddEven/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
def main():
x = int(input())

"""
x & 1 will find out the last bit
if last bit is 1 "x & 1" will return ...0001
if last bit is 0 "x & 1" will return ...0000
"""
if x & 1:
print("Odd")
else:
print("Even")


if __name__ == "__main__":
main()

0 comments on commit 4aae894

Please sign in to comment.