Two numbers form Amicable Pairs if sum of proper divisors of 1st is equal to the 2nd and vice-versa.It is assumed that these two numbers should be distinct,
Example : Let two number 220 And 284 ,
Sum of proper Divisor of 220 := 1+2+4+5+10+11+20+22+44+55+110 = 284
Sum of Proper Divisor of 284 :=1+2+$+71+142=210 .
That's Why 220 & 284 form amicable number pair .
Note : ( 220 , 284 ) smallest Amicable Number Pair .
Related Post : test
your programming skill P-2
C Code to find Amicable Number in GIven Range :
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- long int range, test, chk, div, sum, n1, n2;
- printf("\n\t Enter the Range to Check Amicable Numbers :-");
- scanf("%ld",&range);
- test = 0;
- while( ++test < range )
- {
- sum = div = 0;
- while( ++div <= (test / 2) )
- {
- if( test % div == 0 )
- sum += div;
- }
- chk = sum;
- sum = div = 0;
- while( ++div <= chk/2 )
- {
- if( chk % div == 0 )
- sum += div;
- }
- if( sum == test )
- {
- if( test == chk )
- continue;
- n1 = test;
- if( n1 == n2)
- continue;
- n2 = chk;
- printf("\t%d\t%d\n", n1, n2);
- }
- }
- getch();
- }
Its algorithm is very simple . We choose each number in given range & find sum of its divisor . & check it is amicable pair or NOT but keep in mind that this is slowest approach to do find amicable number . Now Open your mind & Improve this program . (Y)
OUTPUT:
The easy process required for Snap-On Smile procedures is quick and painless,
ReplyDeleteand costs less than dental bridges, porcelain veneers or dental implants.
Ann Hathaway has the big Hollywood smile, the likes we
haven't seen since the days of Julia Robert. Below are some guidelines compiled
from patients for successfully choosing a cosmetic dentist.
Here is my weblog - dentist open on saturday, cosmeticdentistrytreatment.weebly.com,
'Everyone thinks that we're a hate group, we're not a hate group, we don't hate anyone, and we want to see good things come to our race.
ReplyDeleteThe Pitch Drop Experiment - What the heck is a pitch drop experiment.
Reach Time - Reach Time (RT) is the time it
takes foor your message to reach your iintended audience.
Look aat my webb blog :: hay day hack
Heya! I understand this is kind of off-topic howevver I had to ask.
ReplyDeleteDoes building a well-established blog such as
yours take a large amount of work? I aam brand neew to blogging but I do write in my diary on a daily basis.
I'd like to start a blog soo I can easioly share
my own experience aand feelings online. Please
let me know if you have any ideas or tips for new aspiring blog owners.
Appreciate it!
Feel free to surf to my web-site - nhs dental treatment
Thank you for your tіme in filtегing and selecting the vital details on your web-site and re-telling it in ways wɦich iѕs
ReplyDeletecompletely impaгtial and drama free.
Feеl freе to surf to my webloց - e-Liquid
You hold a bright future in writing! Keep uup the great efforts.
ReplyDeleteAlso visit my blog post e-liquid
I like your site and was wondering whether or not you have a problem wifh online hackers?
ReplyDeleteMy latest page was compromised and to my
frustration,destroyed a great deal of workas it wasn't
saved properly. Whatever assistance you can give would be
severely cherished!
Here is my blog post ... eliquid
Wonderful beat ! I wish to apprentice while you
ReplyDeleteamend your site, how could i subscribe for a blog website? The account aided me a acceptable deal.
I had been tiny bit acquainted of this your broadcast offered bright clear
concept
Visit my website ... e liquid