Cody

Problem 42827. Number construction II

Solution 3120721

Submitted on 8 Oct 2020 by Paul Morant
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
n = 28; [a b c d] = numcons(n); assert(all([a b c d]==0))

ans = logical 0

2   Pass
n = 40; [a b c d] = numcons(n); assert(all([a b c d]==0))

ans = logical 0

3   Pass
n = 41; [a b c d] = numcons(n); assert(all([a b c d]==0))

ans = logical 0

4   Pass
n = 26; [a b c d] = numcons(n); assert(all(mod([a b c d],1)==0)) assert(all([a b c d]>1)) assert(a*2^b+c*3^d==n)

ans = logical 1

5   Pass
n = 38; [a b c d] = numcons(n); assert(all(mod([a b c d],1)==0)) assert(all([a b c d]>1)) assert(a*2^b+c*3^d==n)

ans = logical 1

6   Pass
n = 39; [a b c d] = numcons(n); assert(all(mod([a b c d],1)==0)) assert(all([a b c d]>1)) assert(a*2^b+c*3^d==n)

ans = logical 1

7   Pass
n = 555; [a b c d] = numcons(n); assert(all(mod([a b c d],1)==0)) assert(all([a b c d]>1)) assert(a*2^b+c*3^d==n)

ans = logical 1

Suggested Problems

More from this Author34

Community Treasure Hunt

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

Start Hunting!