Cody

Problem 1933. That's some divisor you've got there...

Solution 1529710

Submitted on 15 May 2018 by Sandro Flury
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

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; assert(all(x>0)); 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; assert(all(x>0)); udx=unique(diff(x)); assert(isequal(numel(udx),39)) assert(isequal(sum_divisors(max(udx)),132)) t2=min(100000,t_out); fprintf('Actual Time = %.0f msec\n',t_out) feval(@assignin,'caller','score',floor(t2));

Actual Time = 7 msec Actual Time = 20 msec Actual Time = 22 msec Actual Time = 244 msec Actual Time = 1705 msec Actual Time = 28939 msec Actual Time = 31340 msec Actual Time = 31778 msec

Suggested Problems

More from this Author80

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!