Evil Number Java
The Evil number is another special positive whole number in Java that has an even number of 1's in its binary equivalent. Unlike Prime and Armstrong numbers, Evil number is not so popular and asked by the interviewers.
The numbers which are not evil are called odious numbers. Let's some examples of evil and odious numbers.
In order to check whether the number is evil or not, we have to follow the following steps:
Note: To convert a decimal number into binary, we can use the toBinaryString() in-built method or do it manually by using the loop.
Let's implement the code to check whether the number is evil or not.
Let's implement one more program to get all the Evil numbers in a given range