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’.
- Number of factors of very large number N modulo M where M is any prime number
- 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
- Minimum divisor of a number to make the number perfect cube
- Smallest number dividing minimum number of elements in the array | Set 2
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Smallest number dividing minimum number of elements in the Array
- Find smallest possible Number from a given large Number with same count of digits
- Given number of matches played, find number of teams in tournament
- Number of times the largest perfect square number can be subtracted from N
- Number of possible permutations when absolute difference between number of elements to the right and left are given
- Number of ways to split a binary number such that every part is divisible by 2
- Largest number dividing maximum number of elements in the array
- Build Lowest Number by Removing n digits from a given number
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.