Given a number N, the task is to find the sum of the all Betrothed numbers up to N.
Let, A and B are a Betrothed number pair, then the sum of the proper divisors of A is equal to B+1 and the sum of the proper divisors of B is equal to A+1.
Explanation: 48 and 75 is the only pair of Betrothed Numbers upto 78.
Explanation: There is no pair of Betrothed Numbers up to 50.
- Initialise the array to store all Betrothed numbers upto to N
- Find the Betrothed numbers using sum of all its proper divisors and store the pair in the array.
- Then find the sum all the numbers less than and equal to N.
- The resultant sum is the required value.
Below code is the implementation of the above approach:
Time Complexity: O(N * sqrt(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.
- Check if a given pair of Numbers are Betrothed numbers or not
- Betrothed numbers
- Print all n-digit numbers whose sum of digits equals to given sum
- Sum of sum of all subsets of a set formed by first N natural numbers
- Numbers with sum of digits equal to the sum of digits of its all prime factor
- Find the sum of the all amicable numbers up to N
- Count of numbers satisfying m + sum(m) + sum(sum(m)) = N
- Find K numbers with sum equal to N and sum of their squares maximized
- Print numbers such that no two consecutive numbers are co-prime and every three consecutive numbers are co-prime
- Count numbers which are divisible by all the numbers from 2 to 10
- Maximum sum of distinct numbers such that LCM of these numbers is N
- Absolute Difference between the Sum of Non-Prime numbers and Prime numbers of an Array
- Maximize count of equal numbers in Array of numbers upto N by replacing pairs with their sum
- Count prime numbers that can be expressed as sum of consecutive prime numbers
- Count of N-digit Numbers having Sum of even and odd positioned digits divisible by given numbers
- Compute sum of digits in all numbers from 1 to n
- Print all n-digit numbers with absolute difference between sum of even and odd digits is 1
- Sum of all proper divisors of natural numbers in an array
- Sum of all even numbers in range L and R
- Sum of all numbers divisible by 6 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 email@example.com. 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.