This solution is outdated. To rescore this solution, sign in.
Brilliant, elegant and beautiful...truly pleasing to the eyes. This is what Cody is about. :). On a different note, Solution 1451618, with a size of 74, has an actual performance time of 4582 msec. While, this Solution has 8869 msec. But the problem states that 'Your score will be based on how quickly your script solves the problems in the test suite, rather than the typical Cody size.'. Any explanation on the actual scoring implementation, Bainhome?
Your comment just a chainsaw on my brain...:), first, solutions on this problem's size really baffles me a while,because someone with far more better code skill than me provide lots of code longer than I expected, I am confused about that. Secondly, when I saw your sol.'s size is slightly bigger(which is extremely rare), I have this sneaky smile on my face and close the page as quick as possible. But now I know this problem is about operational efficiency, not size. I'm not in the mood again...:)
But when we talk about operational efficiency, actual time that kinda stuff, I think Sol.1451618 is far more better. Vectoized code deal with large amount data "all at once", and for loop is "one by one", both of them have very different memory burden. and in this particular situation, i.e. very large number, factor... tradtional for loop has a significat advantage.
All above is purely assumption. Viewer discretion is advised.:)
Originally, this problem was scored by how quickly the code solved the problem. The Cody team changed the method of scoring at some point, so the method I used for setting the score proportional to the time spent solving the problem is no longer valid. There are a couple of other problems I have created that have the same issue.
Thanks James. Now I understand. :)
Test  Status  Code Input and Output 

1  Pass 
t_in=clock;
x = 1; y_correct = 1; yours=sum_divisors(x);
assert(isequal(yours,y_correct))
t_out=etime(clock,t_in)*1000;
fprintf('Actual Time = %.0f msec\n',t_out)
x = 2; y_correct = 3; yours=sum_divisors(x);
assert(isequal(yours,y_correct))
t_out=etime(clock,t_in)*1000;
fprintf('Actual Time = %.0f msec\n',t_out)
x = 120; y_correct = 360; yours=sum_divisors(x);
assert(isequal(yours,y_correct))
t_out=etime(clock,t_in)*1000;
fprintf('Actual Time = %.0f msec\n',t_out)
% Perfect Number!
x = 33550336; y_correct = 67100672; yours=sum_divisors(x);
assert(isequal(yours,y_correct))
t_out=etime(clock,t_in)*1000;
fprintf('Actual Time = %.0f msec\n',t_out)
x = 223092870; y_correct = 836075520; yours=sum_divisors(x);
assert(isequal(yours,y_correct))
t_out=etime(clock,t_in)*1000;
fprintf('Actual Time = %.0f msec\n',t_out)
x = 4294967295; y_correct = 7304603328; yours=sum_divisors(x);
assert(isequal(yours,y_correct))
t_out=etime(clock,t_in)*1000;
fprintf('Actual Time = %.0f msec\n',t_out)
x=arrayfun(@(y) sum_divisors(y),1:20000);assert(isequal(sum(x),329004151));
t_out=etime(clock,t_in)*1000;
fprintf('Actual Time = %.0f msec\n',t_out)
x=arrayfun(@(p) sum_divisors(p),primes(200000));assert(isequal(sum(x),1709618797));
t_out=etime(clock,t_in)*1000;
t2=min(100000,t_out);
fprintf('Actual Time = %.0f msec\n',t_out)
feval(@assignin,'caller','score',floor(t2));
Actual Time = 39 msec
Actual Time = 44 msec
Actual Time = 76 msec
Actual Time = 111 msec
Actual Time = 126 msec
Actual Time = 133 msec
Actual Time = 7063 msec
Actual Time = 8869 msec

2228 Solvers
Create an indexpowered vector
229 Solvers
200 Solvers
411 Solvers
197 Solvers