Cody

Problem 83. Prime factor digits

Solution 15274

Submitted on 30 Jan 2012 by Bradley Steel
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 = 2; p_correct = 1; assert(isequal(factor_digits(n),p_correct))

pwithzeros = 0 1 p = 1

2   Pass
%% n = 26; p_correct = [1 0 0 0 0 1]; assert(isequal(factor_digits(n),p_correct))

pwithzeros = 0 0 0 1 0 0 0 0 1 p = 1 0 0 0 0 1

3   Pass
%% n = 168; p_correct = [1 0 1 3]; assert(isequal(factor_digits(n),p_correct))

pwithzeros = Columns 1 through 10 0 0 0 0 0 0 0 0 0 0 Columns 11 through 20 0 0 0 0 0 0 0 0 0 0 Columns 21 through 30 0 0 0 0 0 0 0 0 0 0 Columns 31 through 39 0 0 0 0 0 1 0 1 3 p = 1 0 1 3

4   Pass
%% n = 999; p_correct = [1 0 0 0 0 0 0 0 0 0 3 0]; assert(isequal(factor_digits(n),p_correct))

pwithzeros = Columns 1 through 10 0 0 0 0 0 0 0 0 0 0 Columns 11 through 20 0 0 0 0 0 0 0 0 0 0 Columns 21 through 30 0 0 0 0 0 0 0 0 0 0 Columns 31 through 40 0 0 0 0 0 0 0 0 0 0 Columns 41 through 50 0 0 0 0 0 0 0 0 0 0 Columns 51 through 60 0 0 0 0 0 0 0 0 0 0 Columns 61 through 70 0 0 0 0 0 0 0 0 0 0 Columns 71 through 80 0 0 0 0 0 0 0 0 0 0 Columns 81 through 90 0 0 0 0 0 0 0 0 0 0 Columns 91 through 100 0 0 0 0 0 0 0 0 0 0 Columns 101 through 110 0 0 0 0 0 0 0 0 0 0 Columns 111 through 120 0 0 0 0 0 0 0 0 0 0 Columns 121 through 130 0 0 0 0 0 0 0 0 0 0 Columns 131 through 140 0 0 0 0 0 0 0 0 0 0 Columns 141 through 150 0 0 0 0 0 0 0 0 0 0 Columns 151 through 160 0 0 0 0 0 0 1 0 0 0 Columns 161 through 168 0 0 0 0 0 0 3 0 p = Columns 1 through 10 1 0 0 0 0 0 0 0 0 0 Columns 11 through 12 3 0

Community Treasure Hunt

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

Start Hunting!