Cody

Problem 83. Prime factor digits

Solution 2777746

Submitted on 4 Aug 2020
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   Fail
n = 2; p_correct = 1; assert(isequal(factor_digits(n),p_correct))

gr = 2 gc = 1 a = 1 Primes = 2

Array indices must be positive integers or logical values. Error in factor_digits (line 13) if(Primes(j) == gr(i)) Error in Test1 (line 3) assert(isequal(factor_digits(n),p_correct))

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

gr = 13 2 gc = 1 1 a = 6 Primes = 7 5 3 2

Array indices must be positive integers or logical values. Error in factor_digits (line 13) if(Primes(j) == gr(i)) Error in Test2 (line 3) assert(isequal(factor_digits(n),p_correct))

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

gr = 7 3 2 gc = 1 1 3 a = 4 Primes = Columns 1 through 30 151 149 139 137 131 127 113 109 107 103 101 97 89 83 79 73 71 67 61 59 53 47 43 41 37 31 29 23 19 17 Columns 31 through 36 13 11 7 5 3 2

Array indices must be positive integers or logical values. Error in factor_digits (line 13) if(Primes(j) == gr(i)) Error in Test3 (line 3) assert(isequal(factor_digits(n),p_correct))

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

gr = 37 3 gc = 1 3 a = 12 Primes = Columns 1 through 30 919 911 907 887 883 881 877 863 859 857 853 839 829 827 823 821 811 809 797 787 773 769 761 757 751 743 739 733 727 719 Columns 31 through 60 709 701 691 683 677 673 661 659 653 647 643 641 631 619 617 613 607 601 599 593 587 577 571 569 563 557 547 541 523 521 Columns 61 through 90 509 503 499 491 487 479 467 463 461 457 449 443 439 433 431 421 419 409 401 397 389 383 379 373 367 359 353 349 347 337 Columns 91 through 120 331 317 313 311 307 293 283 281 277 271 269 263 257 251 241 239 233 229 227 223 211 199 197 193 191 181 179 173 167 163 Columns 121 through 150 157 151 149 139 137 131 127 113 109 107 103 101 97 89 83 79 73 71 67 61 59 53 47 43 41 37 31 29 23 19 Columns 151 through 157 17 13 11 7 5 3 2

Array indices must be positive integers or logical values. Error in factor_digits (line 13) if(Primes(j) == gr(i)) Error in Test4 (line 3) assert(isequal(factor_digits(n),p_correct))