my homework-amicable numbers
-
Hi I have a homework about finding amicable numbers [[[[ Amicable numbers:Two numbers are called Amicable(or friendly)if each equals to the sum of the aliquot divisors of the other.Aliquot divisors mean all the divisors excluding the number itself. For example, aliquot divisors of number 220 are 1,2,4,5,10,11,20,22,44,55 and 110. The aliquot divisors of number 284 are 1,2,4,71 and 142. If we represent anamicable pair by(m,n)and sum of aliquot divisors of m and n by(m)and(n)respectively,then for amicable pair(220,284)we get (m)=(220)=1+2+4+5+10+11+20+22+44+55+110=284=n (n)=(284)=1+2+4+71+142=220=m ]]]] my teacher wanted this programs code in C++ without using any arrays(we are allowed to do this with if,while,for,do while).And also the program must be like this: 220 and 284 are amicable numbers. Number of amicable number less than 1000 is 1. 1184 and 1210 are amicable numbers. 2620 and 2924 are amicable numbers. 5020 and 5564 are amicable numbers. 6232 and 6368 are amicable numbers. Number of amicable number less than 10000 is 5. .... .... .... .... It must survive up to 10^10. Please help me,I will so appreciate...:((
-
Hi I have a homework about finding amicable numbers [[[[ Amicable numbers:Two numbers are called Amicable(or friendly)if each equals to the sum of the aliquot divisors of the other.Aliquot divisors mean all the divisors excluding the number itself. For example, aliquot divisors of number 220 are 1,2,4,5,10,11,20,22,44,55 and 110. The aliquot divisors of number 284 are 1,2,4,71 and 142. If we represent anamicable pair by(m,n)and sum of aliquot divisors of m and n by(m)and(n)respectively,then for amicable pair(220,284)we get (m)=(220)=1+2+4+5+10+11+20+22+44+55+110=284=n (n)=(284)=1+2+4+71+142=220=m ]]]] my teacher wanted this programs code in C++ without using any arrays(we are allowed to do this with if,while,for,do while).And also the program must be like this: 220 and 284 are amicable numbers. Number of amicable number less than 1000 is 1. 1184 and 1210 are amicable numbers. 2620 and 2924 are amicable numbers. 5020 and 5564 are amicable numbers. 6232 and 6368 are amicable numbers. Number of amicable number less than 10000 is 5. .... .... .... .... It must survive up to 10^10. Please help me,I will so appreciate...:((
I'll point you in the right direction to help you do it yourself. First off you clearly need a function to compute the aliquot divisor of a number. Second you need to decide how to find the pairs. (assume that you need to detect/avoid duplicates) I think a simple loop can handle this problem. You need to go through the thought process. You can get help for that here - maybe.
-
Hi I have a homework about finding amicable numbers [[[[ Amicable numbers:Two numbers are called Amicable(or friendly)if each equals to the sum of the aliquot divisors of the other.Aliquot divisors mean all the divisors excluding the number itself. For example, aliquot divisors of number 220 are 1,2,4,5,10,11,20,22,44,55 and 110. The aliquot divisors of number 284 are 1,2,4,71 and 142. If we represent anamicable pair by(m,n)and sum of aliquot divisors of m and n by(m)and(n)respectively,then for amicable pair(220,284)we get (m)=(220)=1+2+4+5+10+11+20+22+44+55+110=284=n (n)=(284)=1+2+4+71+142=220=m ]]]] my teacher wanted this programs code in C++ without using any arrays(we are allowed to do this with if,while,for,do while).And also the program must be like this: 220 and 284 are amicable numbers. Number of amicable number less than 1000 is 1. 1184 and 1210 are amicable numbers. 2620 and 2924 are amicable numbers. 5020 and 5564 are amicable numbers. 6232 and 6368 are amicable numbers. Number of amicable number less than 10000 is 5. .... .... .... .... It must survive up to 10^10. Please help me,I will so appreciate...:((
sugaragga wrote:
Please help me...
Exactly which part do you need help with? What code do you have in place so far? What doesn't work?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
I'll point you in the right direction to help you do it yourself. First off you clearly need a function to compute the aliquot divisor of a number. Second you need to decide how to find the pairs. (assume that you need to detect/avoid duplicates) I think a simple loop can handle this problem. You need to go through the thought process. You can get help for that here - maybe.
I cannot do it by myself.I found these codes in this site but it has an array like int get_sumf(int val).We are not allowed to do that.How can I do it without ant array??? #include #define MAX 10000000000 int get_sumf(int val) { int sum = 1; int k; for (k = 2; k <= val / 2; ++k) if (val % k == 0) sum += k; return sum; } int main() { int i, k; for (i = 2; i < MAX; ++i) { int val = get_sumf(i); for (k = 0; k < i; ++k) if (val == k && get_sumf(k) == i) printf("%d %d\n", i, k); } return 0; }
-
Hi I have a homework about finding amicable numbers [[[[ Amicable numbers:Two numbers are called Amicable(or friendly)if each equals to the sum of the aliquot divisors of the other.Aliquot divisors mean all the divisors excluding the number itself. For example, aliquot divisors of number 220 are 1,2,4,5,10,11,20,22,44,55 and 110. The aliquot divisors of number 284 are 1,2,4,71 and 142. If we represent anamicable pair by(m,n)and sum of aliquot divisors of m and n by(m)and(n)respectively,then for amicable pair(220,284)we get (m)=(220)=1+2+4+5+10+11+20+22+44+55+110=284=n (n)=(284)=1+2+4+71+142=220=m ]]]] my teacher wanted this programs code in C++ without using any arrays(we are allowed to do this with if,while,for,do while).And also the program must be like this: 220 and 284 are amicable numbers. Number of amicable number less than 1000 is 1. 1184 and 1210 are amicable numbers. 2620 and 2924 are amicable numbers. 5020 and 5564 are amicable numbers. 6232 and 6368 are amicable numbers. Number of amicable number less than 10000 is 5. .... .... .... .... It must survive up to 10^10. Please help me,I will so appreciate...:((
how can I insert these informations: "Number of amicable number less than 1000 is 1." "Number of amicable number less than 10000 is 5." like this: "220 and 284 are amicable numbers. Number of amicable number less than 1000 is 1. 1184 and 1210 are amicable numbers. 2620 and 2924 are amicable numbers. 5020 and 5564 are amicable numbers. 6232 and 6368 are amicable numbers. Number of amicable number less than 10000 is 5." . I can only write these numbers like: 220 284 1184 1210 2620 2924 5020 5564 6232 6368 .... .... Please help me:((