Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Betrothed numbers in C?
Betrothed numbers are pairs of numbers where the sum of proper divisors of each number equals the other number plus one. In mathematical terms, for numbers (a, b) to be betrothed: s(a) = b + 1 and s(b) = a + 1, where s(n) represents the sum of proper divisors of n (divisors excluding the number itself).
The first few pairs of betrothed numbers are: (48, 75), (140, 195), (1050, 1925), (1575, 1648), (2024, 2295), (5775, 6128). All known pairs have opposite parity − one number is even and the other is odd.
Syntax
int sumOfProperDivisors(int num); int areBetrothed(int a, int b);
Algorithm
- Step 1: Calculate the sum of proper divisors for both numbers (excluding the numbers themselves)
- Step 2: Check if sum of proper divisors of first number equals second number + 1
- Step 3: Check if sum of proper divisors of second number equals first number + 1
- Step 4: If both conditions are true, the numbers are betrothed
Example: Checking Betrothed Numbers
Let's implement a program to check if two numbers form a betrothed pair −
#include <stdio.h>
int sumOfProperDivisors(int num) {
int sum = 0;
for (int i = 1; i < num; i++) {
if (num % i == 0) {
sum += i;
}
}
return sum;
}
int areBetrothed(int a, int b) {
int sumA = sumOfProperDivisors(a);
int sumB = sumOfProperDivisors(b);
return (sumA == b + 1) && (sumB == a + 1);
}
int main() {
int a = 48, b = 75;
printf("Checking if %d and %d are betrothed numbers:
", a, b);
printf("Sum of proper divisors of %d: %d
", a, sumOfProperDivisors(a));
printf("Sum of proper divisors of %d: %d
", b, sumOfProperDivisors(b));
if (areBetrothed(a, b)) {
printf("%d and %d are Betrothed numbers
", a, b);
} else {
printf("%d and %d are not Betrothed numbers
", a, b);
}
return 0;
}
Checking if 48 and 75 are betrothed numbers: Sum of proper divisors of 48: 76 Sum of proper divisors of 75: 49 48 and 75 are Betrothed numbers
Example: Finding First Betrothed Pair
This example finds and verifies the first pair of betrothed numbers −
#include <stdio.h>
int sumOfProperDivisors(int num) {
int sum = 0;
for (int i = 1; i < num; i++) {
if (num % i == 0) {
sum += i;
}
}
return sum;
}
int main() {
int pairs[][2] = {{48, 75}, {140, 195}, {1050, 1925}};
int numPairs = 3;
printf("Verifying betrothed number pairs:
");
for (int i = 0; i < numPairs; i++) {
int a = pairs[i][0];
int b = pairs[i][1];
int sumA = sumOfProperDivisors(a);
int sumB = sumOfProperDivisors(b);
printf("Pair (%d, %d):
", a, b);
printf(" Sum of divisors of %d = %d (should be %d)
", a, sumA, b + 1);
printf(" Sum of divisors of %d = %d (should be %d)
", b, sumB, a + 1);
printf(" Result: %s
",
(sumA == b + 1 && sumB == a + 1) ? "Betrothed" : "Not betrothed");
}
return 0;
}
Verifying betrothed number pairs: Pair (48, 75): Sum of divisors of 48 = 76 (should be 76) Sum of divisors of 75 = 49 (should be 49) Result: Betrothed Pair (140, 195): Sum of divisors of 140 = 196 (should be 196) Sum of divisors of 195 = 141 (should be 141) Result: Betrothed Pair (1050, 1925): Sum of divisors of 1050 = 1926 (should be 1926) Sum of divisors of 1925 = 1051 (should be 1051) Result: Betrothed
Key Points
- Betrothed numbers use proper divisors (excluding the number itself), unlike perfect numbers which include the number
- The condition requires both numbers to satisfy: s(a) = b + 1 AND s(b) = a + 1
- All known betrothed pairs have opposite parity (one even, one odd)
- Time complexity is O(n) for finding sum of divisors of a number n
Conclusion
Betrothed numbers are rare mathematical pairs where each number's proper divisor sum equals the other number plus one. The algorithm efficiently checks this relationship by calculating proper divisor sums and verifying both conditions.
