Given a positive integer N, the task is to check if it is a Proth number. If the given number is a Proth number then print ‘YES’ otherwise print ‘NO’.
Proth Number: In mathematics, a Proth number is a positive integer of the form
n = k * 2n + 1
where k is an odd positive integer and n is a positive integer such that 2n > k .
The first few Proth numbers are –
3, 5, 9, 13, 17, 25, 33, 41, 49, ……
Input: 25 Output: YES Taking k= 3 and n= 3, 25 can be expressed in the form of (k.2n + 1) as (3.23 + 1) Input: 73 Output: NO Taking k=9 and n=3 73 can be expressed in the form of (k.2n + 1 ) as (9.23 + 1) But 23 is less than 9 (it should be greater than k to be Proth Number)
- Deduct 1 from the number. This would give a number in the form k*2n, if the given number is a proth number.
- Now, loop through all odd number starting form k=1 to n/k and check if k can divide n in such a way that ( n/k ) is a power of 2 or not.
- If found, print ‘YES’
- If no such value of k is found then Print ‘NO’
Below is the implementation of above idea
- Program to check Strong Number
- Program to check Plus Perfect Number
- Program to check if N is a Pentagonal Number
- Program to check if a given number is Lucky (all digits are different)
- Program to check if a number is divisible by any of its digits
- Program to check if a number is divisible by sum of its digits
- Recursive program to check if number is palindrome or not
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Check if a number is divisible by all prime divisors of another number
- Check if a number with even number of digits is palindrome or not
- Program to Convert Octal Number to Binary Number
- Program to calculate the number of odd days in given number of years
- Check if a number is a Mystery Number
- How to check if a given number is Fibonacci number?
- Check if a number is a Trojan 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.
Improved By : inderDuMCA