# Some Project Euler pointers requested

Page 1 of 1

## 2 Replies - 698 Views - Last Post: 28 August 2012 - 11:47 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=290298&amp;s=69d58ff42ac4caca561877a31da6b673&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 alexr1090

• D.I.C Head

Reputation: 44
• Posts: 126
• Joined: 08-May 11

# Some Project Euler pointers requested

Posted 28 August 2012 - 08:29 PM

Hi D.I.C. heads. I'm attempting to do some of the Project Euler problems. Right now I'm having trouble with problem 21 and I was hoping I could receive some help for it. I'm not necessarily looking for code, just a point in the right direction. Oh yeah and basically I know this is wrong because I looked up the answer. The correct answer is supposed to be
Spoiler

```def getProperDivisors(x):
ams = []
for y in range(1,x):
if x%y == 0: ams.append(y)
return ams
def addProperDivisors(ams):
total = 0
for x in ams:
total +=x
return total
total = 0
dictionary = {}
for x in range(2,10001):
if x in dictionary:
if dictionary[x] < x:
continue
else:
b = addProperDivisors(getProperDivisors(dictionary[x]))
if b == dictionary[x]:
total += dictionary[x]+ b
continue
a = addProperDivisors(getProperDivisors(x))
dictionary[x] = a
b = addProperDivisors(getProperDivisors(a))
dictionary[a] = b
if a == b:
total += a+b

print total

```

Is This A Good Question/Topic? 0

## Replies To: Some Project Euler pointers requested

### #2 sepp2k

• D.I.C Lover

Reputation: 2308
• Posts: 3,570
• Joined: 21-June 11

## Re: Some Project Euler pointers requested

Posted 28 August 2012 - 11:07 PM

The condition for an amicable pair is that "d(a) = b and d(b) = a, where a ≠ b". Your if condition if a == b does not express that.

This post has been edited by sepp2k: 28 August 2012 - 11:07 PM

Was This Post Helpful? 1

### #3 alexr1090

• D.I.C Head

Reputation: 44
• Posts: 126
• Joined: 08-May 11

## Re: Some Project Euler pointers requested

Posted 28 August 2012 - 11:47 PM

Hey thanks a lot man. That helped me solve it
Was This Post Helpful? 0

Page 1 of 1

 .related ul{list-style-type:circle;font-size:12px;font-weight:bold;}.related li{margin-bottom:5px;background-position:left 7px!important;margin-left:-35px;}.related h2{font-size:18px;font-weight:bold;}.related a{color:blue;}