Some Project Euler pointers requested

Page 1 of 1

2 Replies - 690 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=aa061bd07f270e1580a0403d552354c0&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 alexr1090

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
total = 0
for x in ams:
total +=x
total = 0
dictionary = {}
for x in range(2,10001):
if x in dictionary:
if dictionary[x] < x:
continue
else:
if b == dictionary[x]:
total += dictionary[x]+ b
continue
dictionary[x] = 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: 2296
• Posts: 3,551
• 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

#3 alexr1090

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