Given two positive numbers N and M, the task is to check whether the given pairs of numbers (N, M) form a Betrothed Numbers or not.
Input: N = 48, M = 75
The proper divisors of 48 are 1, 2, 3, 4, 6, 8, 12, 16, 24
Sum of proper divisors of 48 is 75(sum1)
The proper divisors of 75 are 1, 3, 5, 15, 25
Sum of proper divisors of 48 is 49(sum2)
Since sum2 = N + 1, therefore the given pairs form berothered numbers.
Input: N = 95, M = 55
The proper divisors of 95 are 1, 5, 19
Sum of proper divisors of 48 is 25(sum1)
The proper divisors of 55 are 1, 5, 11
Sum of proper divisors of 48 is 17(sum2)
Since Neither sum2 is equals N + 1 nor sum1 is equals to M + 1, therefore the given pairs doesn’t form berothered numbers.
- Find the sum of proper divisors of the given numbers N and M.
- If sum of proper divisors of N is equals to M + 1 or sum of proper divisors of M is equals to N + 1 then the given pairs form a Betrothed Numbers.
- Else it doen’t forms a pair of Betrothed Numbers.
Below is the implementation of the above approach:
Time Complexity: O(√N + √M)
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.
- Betrothed numbers
- Find the sum of all Betrothed numbers up to N
- Check if the given two numbers are friendly pair or not
- Print N lines of 4 numbers such that every pair among 4 numbers has a GCD K
- Print a pair of numbers with the given Sum and Product
- Pair of prime numbers with a given sum and minimum absolute difference
- Check if sum of divisors of two numbers are same
- Check whether product of 'n' numbers is even or odd
- Check whether XOR of all numbers in a given range is even or odd
- Check if two numbers are co-prime or not
- Check if two numbers have same number of digits
- Check the divisibility of Hexadecimal numbers
- Check whether two numbers are in silver ratio
- Check if an Array is a permutation of numbers from 1 to N
- Check whether the two numbers differ at one bit position only
- Check whether the given numbers are Cousin prime or not
- Check whether given three numbers are adjacent primes
- Check whether two numbers are in golden ratio
- Check if an Array is a permutation of numbers from 1 to N : Set 2
- Count of N-digit Numbers having Sum of even and odd positioned digits divisible by given numbers
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.