An engagement number is a pair of two numbers whose sum of the divisors is equal to the other number.
For example, (a, b) is a pair of engagement numbers, if s(a) = b 1 and s(b) = a 1, where s(b) is the sum of equal parts of b: equivalent condition is σ(a) = σ(b) = a b 1, where σ represents the divisor and function.
The first few pairs of engagement numbers are: (48, 75), (140, 195), (1050, 1925) ), (1575, 1648), (2024, 2295), (5775, 6128).
All known pairs of engagement numbers have opposite parity. Any pair of identical parity numbers must exceed 1010.
Step 1: Find the sum of all divisors for both numbers. Step 2: Finally check if the sum of the divisors of number added by one is equal to the other number or not. Step 3: If yes, it is a Betrothed number and otherwise not.
Input:a = 48 b = 75 Output: 48 and 75 are 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.
Use a for loop and check every number from 1 to a-1.
Check to determine whether the number a can be divided, then loop. If so, add this number to aDivisorSum. After the loop completes, aDivisorSum contains the sum of all divisors of a.
Similarly, find the sum of all divisors of the second number and save it in bDivisorSum.
Now check if the sum of the divisors of one number is equal to another number (whether plus one or not). If yes, please print out that both numbers are engagement numbers. Otherwise it is not.
Live demonstration
#include <stdio.h> int main() { int i; int a,b; int aDivisorSum = 0; int bDivisorSum = 0; a=48 ; b=75 ; for( i = 1; i < a; i++) { if(a % i == 0) { aDivisorSum = aDivisorSum + i; } } for( i = 1; i < b; i++) { if(b % i == 0) { bDivisorSum = bDivisorSum + i; } } if(( a+1== bDivisorSum) && (b+1 == aDivisorSum)) { printf("%d and %d are Betrothed numbers</p><p>",a,b); } else { printf("%d and %d are not Betrothed numbers</p><p>",a,b); } }
48 and 75 are not Betrothed numbers
The above is the detailed content of In C language, what does the reserved number mean?. For more information, please follow other related articles on the PHP Chinese website!