Evil Number | Odious Numbers in Java | Evil Number Program in Java | ICSE & ISC 9th-12th | ISC Computer Practical Question 2020 Specimen Paper | ISC Practical 2023 | ICSE Java programs
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.
15 is an evil number because in its binary equivalent, i.e., 1111, it has an even number of ones.
16 is an odious number because in its binary equivalent, i.e., 10000 has not even number of ones
23 is also an evil number because it has an even number of ones in its binary equivalent, i.e., 10111.
In order to check whether the number is evil or not, we have to follow the following steps:
We first take a number.
We then find the binary equivalent of this number and store it into another variable.
We find the total number of ones in the binary number.
If we found an even number of ones in the binary equivalent number, then the number is an evil number. Else the given number is not an evil number.
Music track used :
--------------------------------------------------------------------------
Music track: Fantasy by Pufino
Source: https://freetouse.com/music
Free No Copyright Music Download
Music track: Dreaming After Work by Lukrembo
Source: https://freetouse.com/music
Background Music for Video (Free)
Music track: Life is Beautiful by Aylex
Source: https://freetouse.com/music
Royalty Free Music for Video (Safe)