Cody

# Problem 44705. Expand 10^n to Powers of 4

Solution 2547474

Submitted on 14 Jun 2020 by Nikolaos Nikolaou
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 = 0; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end)) & coeff(1)>0)

ans = 1

2   Pass
n = 1; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end)) & coeff(1)>0)

m = 0 n = 1×0 empty double row vector ans = 2 2

3   Pass
n = 2; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end)) & coeff(1)>0)

m = 32 m = 0 s = 8 n = 0 ans = 4 8 4

4   Pass
n = 3; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end)) & coeff(1)>0)

m = 480 m = 0 s = 30 n = 0 0 ans = 8 30 0 8

5   Pass
n = 4; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end)) & coeff(1)>0)

m = 5888 m = 0 s = 92 n = 0 0 0 ans = 16 92 0 0 16

6   Pass
n = 5; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end)) & coeff(1)>0)

m = 67200 m = 128 s = 262 m = 0 s = 262 2 n = 0 0 0 0 ans = 32 262 2 0 0 32

7   Pass
n = 6; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n)& isequal(coeff(1),coeff(end)) & coeff(1)>0)

m = 737792 m = 512 s = 720 m = 0 s = 720 2 n = 0 0 0 0 0 ans = 64 720 2 0 0 0 64

8   Pass
n = 7; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end)) & coeff(1)>0)

m = 7902720 m = 1536 s = 1929 m = 512 s = 1929 1 m = 0 s = 1929 1 2 n = 0 0 0 0 0 0 ans = 128 1929 1 2 0 0 0 128

9   Pass
n = 8; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end)) & coeff(1)>0)

m = 83222528 m = 8192 s = 5079 m = 0 s = 5079 2 n = 0 0 0 0 0 0 0 ans = 256 5079 2 0 0 0 0 0 256

10   Pass
n = 9; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end)) & coeff(1)>0)

m = 865781760 m = 51200 s = 13210 m = 2048 s = 13210 3 m = 2048 s = 13210 3 0 m = 0 s = 13210 3 0 2 n = 0 0 0 0 0 0 0 0 ans = 512 13210 3 0 2 0 0 0 0 512

11   Pass
n = 10; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end))&coeff(1)>0)

m = 8.9263e+09 m = 253952 s = 34050 m = 57344 s = 34050 3 m = 8192 s = 34050 3 3 m = 0 s = 34050 3 3 2 n = 0 0 0 0 0 0 0 0 0 ans = 1024 34050 3 3 2 0 0 0 0 0 1024

12   Pass
n = 11; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end))&coeff(1)>0)

m = 9.1410e+10 m = 450560 s = 87175 m = 188416 s = 87175 1 m = 57344 s = 87175 1 2 m = 8192 s = 87175 1 2 3 m = 0 s = 87175 1 2 3 2 n = 0 0 0 0 0 0 0 0 0 0 ans = 2048 87175 1 2 3 2 0 0 0 0 0 2048

13   Pass
n = 12; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end))&coeff(1)>0)

m = 9.3128e+11 m = 2424832 s = 222034 m = 327680 s = 222034 2 m = 65536 s = 222034 2 1 m = 0 s = 222034 2 1 1 n = 0 0 0 0 0 0 0 0 0 0 0 ans = 4096 222034 2 1 1 0 0 0 0 0 0 0 4096

14   Pass
n = 13; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end))&coeff(1)>0)

m = 9.4502e+12 m = 7503872 s = 563278 m = 3309568 s = 563278 1 m = 163840 s = 563278 1 3 m = 163840 s = 563278 1 3 0 m = 32768 s = 563278 1 3 0 2 m = 0 s = 563278 1 3 0 2 2 n = 0 0 0 0 0 0 0 0 0 0 0 0 ans = 8192 563278 1 3 0 2 2 0 0 0 0 0 0 8192

15   Pass
n = 14; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end))&coeff(1)>0)

m = 9.5602e+13 m = 7995392 s = 1424580 m = 7995392 s = 1424580 0 m = 3801088 s = 1424580 0 1 m = 655360 s = 1424580 0 1 3 m = 131072 s = 1424580 0 1 3 2 m = 0 s = 1424580 0 1 3 2 2 n = 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = Columns 1 through 14 16384 1424580 0 1 3 2 2 0 0 0 0 0 0 0 Column 15 16384

16   Pass
n = 15; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end))&coeff(1)>0)

m = 9.6482e+14 m = 80084992 s = 3594218 m = 12976128 s = 3594218 1 m = 12976128 s = 3594218 1 0 m = 393216 s = 3594218 1 0 3 m = 393216 s = 3594218 1 0 3 0 m = 131072 s = 3594218 1 0 3 0 1 m = 0 s = 3594218 1 0 3 0 1 2 n = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = Columns 1 through 14 32768 3594218 1 0 3 0 1 2 0 0 0 0 0 0 Columns 15 through 16 0 32768

17   Pass
n = 16; coeff = ten2pow4(n); assert(isequal(dot(coeff, 4.^flip(0:n)),10^n) & isequal(coeff(1),coeff(end)) & coeff(1)>0)

m = 9.7185e+15 m = 801112064 s = 9051081 m = 264241152 s = 9051081 2 m = 62914560 s = 9051081 2 3 m = 12582912 s = 9051081 2 3 3 m = 0 s = 9051081 2 3 3 3 n = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = Columns 1 through 14 65536 9051081 2 3 3 3 0 0 0 0 0 0 0 0 Columns 15 through 17 0 0 65536