{"id":17350,"date":"2021-08-26T10:42:39","date_gmt":"2021-08-26T05:12:39","guid":{"rendered":"https:\/\/python-programs.com\/?p=17350"},"modified":"2021-11-22T18:37:11","modified_gmt":"2021-11-22T13:07:11","slug":"python-program-to-check-evil-number-or-not","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-check-evil-number-or-not\/","title":{"rendered":"Python Program to Check Evil Number or Not"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Determine Whether one String is a Rotation of Another<\/a>
\nEvil Number :<\/strong><\/p>\n

The Evil number is another unique positive whole number with an even number of 1s in its binary representation.<\/p>\n

example:<\/p>\n

1) let n= 12<\/p>\n

binary representation = 1100<\/p>\n

# It has an even number of 1’s.\u00a0 Therefore 12 is an evil number.<\/p>\n

2) n= 4<\/p>\n

binary representation = 100<\/p>\n

It has an odd number of 1’s.\u00a0 Therefore 4 is not an evil number.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 6<\/pre>\n

Output:<\/strong><\/p>\n

The given number 6 is an Evil Number<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 22<\/pre>\n

Output:<\/strong><\/p>\n

The given number 22 is Not an Evil Number<\/pre>\n

Program to Check Evil Number or Not<\/h2>\n

Below are the ways to check whether the given number is an evil number or not<\/p>\n