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
- Count elements in the given range which have maximum number of divisors
- Find the largest good number in the divisors of given number N
- Find number from its divisors
- Find the sum of the number of 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
- Find the number of integers from 1 to n which contains digits 0's and 1's only
- Find integers that divides maximum number of elements of the array
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.