Betrothed numbers are two positive numbers such that the sum of the proper divisors of either number is one more than (or one plus) the value of the other number. Our task is to find these pairs efficiently.
(48, 75) is an example of Betrothed numbers Divisors of 48 : 1, 2, 3, 4, 6, 8, 12, 16, 24. Their sum is 76. Divisors of 75 : 1, 3, 5, 15, 25. Their sum is 49.
Given a positive integer n, print all Brothered numbers (which is a pair) such that one of the numbers in every pair is smaller than n.
Input : n = 1000 Output : (48, 75) Input : n = 10000 Output : (48, 75), (140, 195), (1050, 1925) (1575, 1648), (2024, 2295), (5775, 6128) (8892, 16587), (9504, 20735)
The idea used in below program is simple. We traverse through all numbers from 1 to n-1. For every number num1, we find sum of its proper divisors say sum1. After finding sum1, we check if the number num2 = sum1 + 1 which has sum of divisors as num1 + 1
(48, 75) (140, 195) (1050, 1925) (1575, 1648) (2024, 2295) (5775, 6128) (8892, 16587) (9504, 20735)
This article is contributed by Shlomi Elhaiani. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Permutation of numbers such that sum of two consecutive numbers is a perfect square
- Print N lines of 4 numbers such that every pair among 4 numbers has a GCD K
- Numbers within a range that can be expressed as power of two numbers
- Numbers less than N which are product of exactly two distinct prime numbers
- Count numbers which can be constructed using two numbers
- Maximum sum of distinct numbers such that LCM of these numbers is N
- Count numbers which are divisible by all the numbers from 2 to 10
- Absolute difference between the Product of Non-Prime numbers and Prime numbers of an Array
- Absolute Difference between the Sum of Non-Prime numbers and Prime numbers of an Array
- Print numbers such that no two consecutive numbers are co-prime and every three consecutive numbers are co-prime
- Add two numbers using ++ and/or --
- Sum of first n even numbers
- Sum of all even numbers in range L and R
- Sum of square of first n even numbers
- Sum of square of first n odd numbers