Given a positive integer n, the task is to check if it is a Thabit number. If the given number is a Thabit number then print ‘YES’ otherwise print ‘NO’.
Thabit number: In mathematics, a Thabit Number is a positive integer of the form 3* 2n – 1, where n is a non negative integer.
The first few Thabit numbers are –
2, 5, 11, 23, 47, 95, 191, 383, 767, 1535, 3071, 6143, 12287, 24575, 49151, 98303, 196607, 393215,
Input : 47
Output : YES
Explanation : for n=4, 47 can be expressed in the form of 3.2n -1 as 3.24 -1.
Output : NO
No such value of n exist for which 65 can be expressed in the form of 3.2n – 1
- Add 1 to the given number, Now the number must be of the form 3*2n
- Divide the number by 3, By now the number must be of the form 2n
- Check if the number is a power of 2 or not, To check if the number is power of two or not refer this .
- If the number is power of 2 then Print ‘YES’ otherwise ‘NO’.
- Count number of trailing zeros in Binary representation of a number using Bitset
- Count number of triplets with product equal to given number with duplicates allowed
- Find minimum number to be divided to make a number a perfect square
- Smallest number dividing minimum number of elements in the array | Set 2
- Number of times the largest perfect square number can be subtracted from N
- Largest number dividing maximum number of elements in the array
- Number of possible permutations when absolute difference between number of elements to the right and left are given
- Smallest number dividing minimum number of elements in the Array
- Number of ways to split a binary number such that every part is divisible by 2
- Given number of matches played, find number of teams in tournament
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Build Lowest Number by Removing n digits from a given number
- Number of digits to be removed to make a number divisible by 3
- Querying maximum number of divisors that a number in a given range has
- Find the number of ways to divide number into four parts such that a = c and b = d
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.