Evil Number JavaThe 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. EvilNumberExample.java Output Let's implement one more program to get all the Evil numbers in a given range FindAllEvilNumber.java Output Next TopicISBN Number Java |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India