Question:

CALLING ALL SMART PEOPLE. I HAVE one hard a$ question for you!?

by  |  earlier

0 LIKES UnLike

A pair of distinct integers is considered amicable if the sum of proper divisors for one number equals the second and vice versa.

Example: 220, 284

220=2^2*5*11 (1+2+4+5+10+11+20+22+44+55+110 = 284)

284=2^2*71 (1+2+4+71+142 = 220)

Consider the ratio of the sum of the divisors of a natural number by the number itself, R(n). If two distinct natural numbers have equal ratios, those numbers are said to be "friendly".

Example: 30, 140

R(30) = (1+2+3+5+6+10+15+30)/30 = 12/5

R(140) = (1+2+4+5+7+10+14+20+28+35+70+140)/140 = 12/5

Problem: Write a threaded application to find and print each pair of amicable numbers and each pair of friendly numbers that are both within the given input range. The range, two positive integers, is to be given to the application as it begins execution, nominally as command line arguments.

Example execution:

> amicable.exe 200 600

220 and 284 are AMICABLE

240 and 600 are FRIENDLY

Restrictions: No direct knowledge or information may be encoded into the source files or auxiliary files used by the applications. For example, no tables of prime numbers or lists of amicable numbers or friendly numbers may be used. All such information must be generated by the application at run-time.

 Tags:

   Report

7 ANSWERS


  1. Sounds like the hardest part will be writing a routine to compute a list of all of the proper divisors of any given number.

    From there, you'll need two tables, each the size of (max - min + 1).  For each number in the range, you'll have to compute the divisor list, sum the list, and store it in the first table.  Then divide by your current number to get the "friendly" number.  At the end, you'll have to go through the two lists to find matched sets.

    Thread it by giving each thread a different range of numbers to fill in the table for, so that you're doing it in parallel.  It's an interesting problem, although I can't imagine where I'd use it real life.  But that's school for you.

    Hope that helps...


  2. Sounds like a fun Java project. Don't forget to use the Thread class.

  3. I can't think of any way other than using brute force to check every pair of numbers within the range. The main thing would be determining the divisors of a number, which would also require brute force. So, it looks hopeless to me.

  4. WOW ummm i do not get that at all its kinda scary!!

    so um mm ya who would get that NOT ME!  Sorry i was no help,,, and im smart!!!

    Sorry

    HeMMy 320

  5. well u do somthing with the numbers and stuff and mutipla the Abercrombie by the freindy @@@&& 2*F (1+@+7=9Xhj91+8+266666=)

  6. Tsk, tsk.

    If you want to win that Intel Threading Challenge you'll need to do it yourself.

  7. huh?

Question Stats

Latest activity: earlier.
This question has 7 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.