Monday 10 March 2014

AMICABLE PAIRS


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 . 

C Code to find Amicable Number in GIven Range : 




  1. #include<stdio.h>  
  2.  #include<conio.h>  
  3.  void main()  
  4.  {  
  5.    long int range, test, chk, div, sum, n1, n2;  
  6.    printf("\n\t Enter the Range to Check Amicable Numbers :-");  
  7.    scanf("%ld",&range);  
  8.    test = 0;  
  9.    while( ++test < range )  
  10.    {  
  11.        sum = div = 0;  
  12.        while( ++div <= (test / 2) )  
  13.        {  
  14.            if( test % div == 0 )  
  15.              sum += div;  
  16.        }  
  17.        chk = sum;  
  18.        sum = div = 0;  
  19.        while( ++div <= chk/2 )  
  20.        {  
  21.            if( chk % div == 0 )  
  22.              sum += div;  
  23.        }  
  24.        if( sum == test )  
  25.        {  
  26.          if( test == chk )  
  27.             continue;  
  28.          n1 = test;  
  29.          if( n1 == n2)  
  30.             continue;  
  31.          n2 = chk;  
  32.          printf("\t%d\t%d\n", n1, n2);  
  33.        }  
  34.    }  
  35.   getch();  
  36.  }


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:


THANK YOU...........


7 comments:

  1. The easy process required for Snap-On Smile procedures is quick and painless,
    and 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,

    ReplyDelete
  2. '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.
    The 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

    ReplyDelete
  3. Heya! I understand this is kind of off-topic howevver I had to ask.
    Does 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

    ReplyDelete
  4. 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
    completely impaгtial and drama free.

    Feеl freе to surf to my webloց - e-Liquid

    ReplyDelete
  5. You hold a bright future in writing! Keep uup the great efforts.


    Also visit my blog post e-liquid

    ReplyDelete
  6. I like your site and was wondering whether or not you have a problem wifh online hackers?
    My 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

    ReplyDelete
  7. Wonderful beat ! I wish to apprentice while you
    amend 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

    ReplyDelete

THANKS FOR UR GREAT COMMENT

Blogger Widgets