Cody

Solution 1854743

Submitted on 20 Jun 2019 at 22:47 by David Hill
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
p = 5; [Nopt,prd] = max_product(p); assert(isequal(Nopt,3)) assert(abs(prd - 4.62962962962963)/4.62962962962963 < 1e-13)

2   Pass
p = 10; [Nopt,prd] = max_product(p); assert(isequal(Nopt,4)) assert(abs(prd - 39.0625)/39.0625 < 1e-13)

3   Pass
p = 17.5; [Nopt,prd] = max_product(p); assert(isequal(Nopt,6)) assert(abs(prd - 615.631438413601)/615.631438413601 < 1e-13)

4   Pass
p = 29; [Nopt,prd] = max_product(p); assert(isequal(Nopt,11)) assert(abs(prd - 4.276204243443044e+04)/4.276204243443044e+04 < 1e-13)

5   Pass
p = 49; [Nopt,prd] = max_product(p); assert(isequal(Nopt,18)) assert(abs(prd - 6.739448339947788e+07)/6.739448339947788e+07 < 1e-13)

6   Pass
p = 256; [Nopt,prd] = max_product(p); assert(isequal(Nopt,94)) assert(abs(prd - 7.953137683223010e+40)/7.953137683223010e+40 < 1e-13)

7   Pass
p = 1000000; [Nopt,prd] = max_product(p); assert(isequal(Nopt,367879)) assert(isinf(prd))