[Community puzzle] Sum of divisors


#1

The maximum limit should be increased. Brute force solution in Java does not time out at 100000, but does time out at 1000000. I suggest to set the limit even higher, to 10000000 or something.


#2

Go java. To see a brute force solution that doesn't time out, please visit my solution.


#3

To be fair, sd23152243 brute forced it first successfully according to the solution history in java at least.


#4

I use Python3..

The last case always timeout.. The greatest value of N that runs for me is 12760

N>=12761 → Timeout..

Is this an optimisation work or the IDE will not support more than that :confused:

cc @nicola


#5

This means your algo is not optimal. You need to find a better algorithm.


#6

Your algorithm is too slow.
Find another one.


#7

I've used brute force in C (but no factorization) and doesn't timeout until the maximum result representable as a int64 (wich is for n = 100889). However it does time out for n = 117739.

I confess I wasn't able to disvover the trick :frowning:. I'm going to check other's solutions.


#8

Increase the limit. You can easily brute force by checking only upto sqrt of a number to find all factors.


#9

Hello guys. I was working on this puzzle today. I thought I found a good solution, giving me the sum in a quick time, but when it get to the last test, I get “-1927827902” as a result. No “timeout error”. Any idea why?
Python code worked fine but this time it’s in C# and this error occurs.


#10

Because your int is not long enough in C#.


#11

Damn, it was as simple as using long instead of int…I feel so dumb ! Thanks nicola1 !