Cody

Solution 1810760

Submitted on 9 May 2019 by Binbin Qi
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
x = 1; y_correct = 1; assert(isequal(two_fractions(x),y_correct))

2   Pass
x = 10; y_correct = 5; assert(isequal(two_fractions(x),y_correct))

3   Pass
x = 120; y_correct = 32; assert(isequal(two_fractions(x),y_correct))

4   Pass
x = 9240; y_correct = 284; assert(isequal(two_fractions(x),y_correct))

5   Pass
x = 510510; y_correct = 1094; assert(isequal(two_fractions(x),y_correct))

6   Pass
x = 223092869; y_correct = 14; assert(isequal(two_fractions(x),y_correct))

7   Pass
x = 223092870; y_correct = 9842; assert(isequal(two_fractions(x),y_correct))

8   Pass
x = 223092871; y_correct = 5; assert(isequal(two_fractions(x),y_correct))

9   Pass
t7=two_fractions(10^7); t8=two_fractions(10^8); t9=two_fractions(10^9); x1=str2num(sprintf('%g',t7,t8,t9)) assert(isprime(x1)); assert(x1>1e8); x2=str2num(sprintf('%g',t9,t8,t7)) fx2=factor(x2); assert(numel(fx2)==2); assert(all(fx2>10000)); assert(isequal(two_fractions(t7+t8+t9),2)); assert(isequal(two_fractions(x1+x2),two_fractions(x2)));

x1 = 113145181 x2 = 181145113

10   Pass
tic satf=sum(arrayfun(@(x) two_fractions(x),1:10000)); assert(isequal(satf,186991)) toc

Elapsed time is 3.685828 seconds.

Suggested Problems

More from this Author80