Cody

# Problem 44071. Smallest n, for n! to have m trailing zero digits

Solution 3215758

Submitted on 15 Oct 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   Pass
m = 1; n_correct = 5; assert(isequal(factorialForZeros(m),n_correct))

n = 5

2   Pass
m = 2; n_correct = 10; assert(isequal(factorialForZeros(m),n_correct))

low = 0 high = 10 mid = 5 numStr = '5' count = 0 trail = 5 tf = logical 0 low = 6 mid = 8 numStr = '8' count = 0 trail = 8 tf = logical 0 low = 9 mid = 9 numStr = '9' count = 0 trail = 9 tf = logical 0 low = 10 n = 10

3   Fail
m = 6; n_correct = 25; assert(isequal(factorialForZeros(m),n_correct))

low = 0 high = 30 mid = 15 numStr = '15' count = 0 trail = 15 tf = logical 0 low = 16 mid = 23 numStr = '23' count = 0 trail = 23 tf = logical 0 low = 24 mid = 27 numStr = '27' count = 0 trail = 27 tf = logical 0 low = 28 mid = 29 numStr = '29' count = 0 trail = 29 tf = logical 0 low = 30 n = 30

Assertion failed.

4   Pass
m = 5; n_correct = 25; assert(isequal(factorialForZeros(m),n_correct))

low = 0 high = 25 mid = 12 numStr = '12' count = 0 trail = 12 tf = logical 0 low = 13 mid = 19 numStr = '19' count = 0 trail = 19 tf = logical 0 low = 20 mid = 22 numStr = '22' count = 0 trail = 22 tf = logical 0 low = 23 mid = 24 numStr = '24' count = 0 trail = 24 tf = logical 0 low = 25 n = 25

5   Pass
m = 4; n_correct = 20; assert(isequal(factorialForZeros(m),n_correct))

low = 0 high = 20 mid = 10 numStr = '10' count = 0 trail = 10 tf = logical 0 low = 11 mid = 15 numStr = '15' count = 0 trail = 15 tf = logical 0 low = 16 mid = 18 numStr = '18' count = 0 trail = 18 tf = logical 0 low = 19 mid = 19 numStr = '19' count = 0 trail = 19 tf = logical 0 low = 20 n = 20

6   Fail
m = 156; n_correct = 625; assert(isequal(factorialForZeros(m),n_correct))

low = 0 high = 780 mid = 390 numStr = '390' count = 0 trail = 390 tf = logical 0 low = 391 mid = 585 numStr = '585' count = 0 trail = 585 tf = logical 0 low = 586 mid = 683 numStr = '683' count = 0 trail = 683 tf = logical 0 low = 684 mid = 732 numStr = '732' count = 0 trail = 732 tf = logical 0 low = 733 mid = 756 numStr = '756' count = 0 trail = 756 tf = logical 0 low = 757 mid = 768 numStr = '768' count = 0 trail = 768 tf = logical 0 low = 769 mid = 774 numStr = '774' count = 0 trail = 774 tf = logical 0 low = 775 mid = 777 numStr = '777' count = 0 trail = 777 tf = logical 0 low = 778 mid = 779 numStr = '779' count = 0 trail = 779 tf = logical 0 low = 780 n = 780

Assertion failed.

7   Fail
m = 155; n_correct = 625; assert(isequal(factorialForZeros(m),n_correct))

low = 0 high = 775 mid = 387 numStr = '387' count = 0 trail = 387 tf = logical 0 low = 388 mid = 581 numStr = '581' count = 0 trail = 581 tf = logical 0 low = 582 mid = 678 numStr = '678' count = 0 trail = 678 tf = logical 0 low = 679 mid = 727 numStr = '727' count = 0 trail = 727 tf = logical 0 low = 728 mid = 751 numStr = '751' count = 0 trail = 751 tf = logical 0 low = 752 mid = 763 numStr = '763' count = 0 trail = 763 tf = logical 0 low = 764 mid = 769 numStr = '769' count = 0 trail = 769 tf = logical 0 low = 770 mid = 772 numStr = '772' count = 0 trail = 772 tf = logical 0 low = 773 mid = 774 numStr = '774' count = 0 trail = 774 tf = logical 0 low = 775 n = 775

Assertion failed.

8   Fail
m = 154; n_correct = 625; assert(isequal(factorialForZeros(m),n_correct))

low = 0 high = 770 mid = 385 numStr = '385' count = 0 trail = 385 tf = logical 0 low = 386 mid = 578 numStr = '578' count = 0 trail = 578 tf = logical 0 low = 579 mid = 674 numStr = '674' count = 0 trail = 674 tf = logical 0 low = 675 mid = 722 numStr = '722' count = 0 trail = 722 tf = logical 0 low = 723 mid = 746 numStr = '746' count = 0 trail = 746 tf = logical 0 low = 747 mid = 758 numStr = '758' count = 0 trail = 758 tf = logical 0 low = 759 mid = 764 numStr = '764' count = 0 trail = 764 tf = logical 0 low = 765 mid = 767 numStr = '767' count = 0 trail = 767 tf = logical 0 low = 768 mid = 769 numStr = '769' count = 0 trail = 769 tf = logical 0 low = 770 n = 770

Assertion failed.

9   Fail
m = 153; n_correct = 625; assert(isequal(factorialForZeros(m),n_correct))

low = 0 high = 765 mid = 382 numStr = '382' count = 0 trail = 382 tf = logical 0 low = 383 mid = 574 numStr = '574' count = 0 trail = 574 tf = logical 0 low = 575 mid = 670 numStr = '670' count = 0 trail = 670 tf = logical 0 low = 671 mid = 718 numStr = '718' count = 0 trail = 718 tf = logical 0 low = 719 mid = 742 numStr = '742' count = 0 trail = 742 tf = logical 0 low = 743 mid = 754 numStr = '754' count = 0 trail = 754 tf = logical 0 low = 755 mid = 760 numStr = '760' count = 0 trail = 760 tf = logical 0 low = 761 mid = 763 numStr = '763' count = 0 trail = 763 tf = logical 0 low = 764 mid = 764 numStr = '764' count = 0 trail = 764 tf = logical 0 low = 765 n = 765

Assertion failed.

10   Fail
m = 152; n_correct = 620; assert(isequal(factorialForZeros(m),n_correct))

low = 0 high = 760 mid = 380 numStr = '380' count = 0 trail = 380 tf = logical 0 low = 381 mid = 570 numStr = '570' count = 0 trail = 570 tf = logical 0 low = 571 mid = 665 numStr = '665' count = 0 trail = 665 tf = logical 0 low = 666 mid = 713 numStr = '713' count = 0 trail = 713 tf = logical 0 low = 714 mid = 737 numStr = '737' count = 0 trail = 737 tf = logical 0 low = 738 mid = 749 numStr = '749' count = 0 trail = 749 tf = logical 0 low = 750 mid = 755 numStr = '755' count = 0 trail = 755 tf = logical 0 low = 756 mid = 758 numStr = '758' count = 0 trail = 758 tf = logical 0 low = 759 mid = 759 numStr = '759' count = 0 trail = 759 tf = logical 0 low = 760 n = 760

Assertion failed.

### Community Treasure Hunt

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

Start Hunting!