Given an integer N. The task is to find the number of integers 1 < x < N, for which x and x + 1 have the same number of positive divisors.
Input: N = 3
Divisors(1) = 1
Divisors(2) = 1 and 2
Divisors(3) = 1 and 3
Only valid x is 2.
Input: N = 15
Approach: Find the number of divisors of all numbers below N and store them in an array. And count the number of integers x such that x and x + 1 have the same number of positive divisors by running a loop.
Below is the implementation of the above approach:
- Find the number of divisors of all numbers in the range [1, n]
- Program to find count of numbers having odd number of divisors in given range
- Querying maximum number of divisors that a number in a given range has
- Count number of integers less than or equal to N which has exactly 9 divisors
- Find sum of divisors of all the divisors of a natural number
- Find sum of inverse of the divisors when sum of divisors and the number is given
- Count elements in the given range which have maximum number of divisors
- Find the largest good number in the divisors of given number N
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Find the sum of the number of divisors
- Find number from its divisors
- Find all divisors of a natural number | Set 1
- Find all divisors of a natural number | Set 2
- Find numbers with K odd divisors in a given range
- Find numbers with n-divisors in a given range
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.