A Woodall number is of the form:
Wn = n.2n – 1
The first few Woodall numbers are: 1, 7, 23, 63, 159, 383, 895……
Given a number X. The task is to check if X is woodall number or not.
Input : X = 383 Output : Yes For n = 6, Wn = n.2n - 1 = 383. Input : X = 200 Output : No
- We can observe that all Woodall numbers are odd. So, first of all we check if given number is odd or not.
- Now to check if number is woodall or not, increment given number by 1 and now divide number by 2 until it is even and count number of times it is divisible. And at each point check if count is equal to number or not.
Below is the implementation of this approach:
This article is contributed by Anuj Chauhan. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Count number of trailing zeros in Binary representation of a number using Bitset
- Find minimum number to be divided to make a number a perfect square
- Count number of triplets with product equal to given number with duplicates allowed
- Number of times the largest perfect square number can be subtracted from N
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Given number of matches played, find number of teams in tournament
- Number of ways to split a binary number such that every part is divisible by 2
- Number of possible permutations when absolute difference between number of elements to the right and left are given
- Print a number strictly less than a given number such that all its digits are distinct.
- Program to Convert Octal Number to Binary Number
- Super Ugly Number (Number whose prime factors are in given set)
- Count number of ways to divide a number in 4 parts
- Minimum number of given powers of 2 required to represent a number
- Querying maximum number of divisors that a number in a given range has
- Queries on sum of odd number digit sums of all the factors of a number
Improved By : vt_m