Given an integer N, the task is to count all pairs of divisors of N such that the sum of each pair is coprime with N.
Input: N = 24
There are 2 pairs (1, 24) and (2, 3) whose sum is coprime with 24
There are 4 pairs (1, 105), (3, 35), (5, 21) and (7, 15) whose sum is coprime with 105
To solve the problem mentioned above we can easily calculate the result by finding all divisors in √N complexity, and check for each pair, whether its sum is coprime with N or not.
Below is the implementation of the above approach:
Time Complexity: O(√N * log(N))
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Count of integers up to N which are non divisors and non coprime with N
- Coprime divisors of a number
- Check if a number has an odd count of odd divisors and even count of even 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
- Check if count of even divisors of N is equal to count of odd divisors
- Count of numbers below N whose sum of prime divisors is K
- Print all Coprime path of a Binary Tree
- Print all distinct Coprime sets possible from 1 to N
- First triangular number whose number of divisors exceeds N
- Divisors of n-square that are not divisors of n
- Maximum possible prime divisors that can exist in numbers having exactly N divisors
- Sum of product of all integers upto N with their count of divisors
- Sum of all prime divisors of all the numbers in range L-R
- Finding a Non Transitive Coprime Triplet in a Range
- Count all perfect divisors of a number
- Sum of all proper divisors of a natural number
- Sum of all the prime divisors of a number
- Break a number such that sum of maximum divisors of all parts is minimum
- Sum of all second largest divisors after splitting a number into one or more parts
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 : equbalzeeshan