Odious number is a nonnegative number that has an odd number of 1s in its binary expansion. The first few odious numbers are therefore 1, 2, 4, 7, 8, 11, 13, 14, 16, 19…
Given a number check if its a odious number or not.
Input : 16 Output : Odious Number Explanation: Binary expansion of 16 = 10000, having number of 1s =1 i.e odd. Input : 23 Output : Not odious number Explanation: Binary expansion of 23 is 10111, the number of 1s in this is 4 i.e even.
1) Count set bits in given number.
2) Return true if the count is odd, false otherwise.
- Count number of trailing zeros in Binary representation of a number using Bitset
- Maximize a given unsigned number number by swapping bits at it's extreme positions.
- Check if the binary representation of a number has equal number of 0s and 1s in blocks
- Find a number which give minimum sum when XOR with every number of array of integers
- Number of leading zeros in binary representation of a given number
- Super Ugly Number (Number whose prime factors are in given set)
- Minimum number of given powers of 2 required to represent a number
- Finding number of digits in n'th Fibonacci number
- Check if a number has same number of set and unset bits
- Find the Number Occurring Odd Number of Times
- Check if a number is an Achilles number or not
- M-th smallest number having k number of set bits.
- Number of integers with odd number of set bits
- Minimum number using set bits of a given number
- Next higher number with same number of set bits
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Mithun Kumar