0
$\begingroup$

Psd(x) denotes the sum of digits of all positive integer divisors of x where x>0. For example, Psd(15)=1+3+5+1+5=14 (divisors: 1,3,5,15)

What is x for the biggest value of Psd(x) where x<10000.

$\endgroup$
4
  • $\begingroup$ I would bet on 7560 or 9240, both of which have 64 divisors. I don't see a good way to be certain without a brute force search. $\endgroup$ Jan 17, 2016 at 23:48
  • $\begingroup$ So you're looking for the largest perfect number <10000? $\endgroup$ Jan 18, 2016 at 6:52
  • $\begingroup$ no, function is not exactly largest perfect number. $\endgroup$
    – Oray
    Jan 18, 2016 at 6:55
  • $\begingroup$ Maybe a program could solve this $\endgroup$
    – Daedric
    Jan 18, 2016 at 10:33

1 Answer 1

0
$\begingroup$

Here's a simple Python bruteforce program that gets the job done:

from math import sqrt

maxNum = -1
maxSum = 0
for x in range(1, 10000):
  currentSum = 0
  for d in range(1, int(sqrt(x)) + 1):
    if(x % d == 0):
      for digit in str(d):
        currentSum += int(digit)
      for digit in str(x / d):
        currentSum += int(digit)
  if currentSum > maxSum:
    maxSum = currentSum
    maxNum = x

print "Maximum sum: {}.\n{}:".format(maxSum, maxNum)
for d in range(1, int(sqrt(maxNum)) + 1):
  if(maxNum % d == 0):
    print "  = {} x {}".format(d, maxNum / d)

Output:

Maximum sum: 549.
7920:
  = 1 x 7920
  = 2 x 3960
  = 3 x 2640
  = 4 x 1980
  = 5 x 1584
  = 6 x 1320
  = 8 x 990
  = 9 x 880
  = 10 x 792
  = 11 x 720
  = 12 x 660
  = 15 x 528
  = 16 x 495
  = 18 x 440
  = 20 x 396
  = 22 x 360
  = 24 x 330
  = 30 x 264
  = 33 x 240
  = 36 x 220
  = 40 x 198
  = 44 x 180
  = 45 x 176
  = 48 x 165
  = 55 x 144
  = 60 x 132
  = 66 x 120
  = 72 x 110
  = 80 x 99
  = 88 x 90

Good guess @Ross Millikan.

$\endgroup$
1
  • $\begingroup$ @Oray I barely released my mouse button before you accepted it. Nice reflexes lol. $\endgroup$ Jan 18, 2016 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.