[Community puzzle] Sum of divisors

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.

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

1 Like

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

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

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

1 Like

Your algorithm is too slow.
Find another one.

1 Like

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.

1 Like

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

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.

Because your int is not long enough in C#.

1 Like

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

when you know the trick the solution can be written in one line
even with a slow language like ruby i got the corrent answer for 18562354 : 283390055742558