Cody

# Problem 44068. The number of trailing zero digit of a factorial

Solution 1739679

Submitted on 1 Mar 2019 by Martin C.
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 = 1; ct_correct = 0; assert(isequal(powerTenInFactorial(n),ct_correct))

f = [] f = 1 twos = 0 fives = 0 ct = 0

2   Pass
n = 9; ct_correct = 1; assert(isequal(powerTenInFactorial(n),ct_correct))

f = [] f = 1 f = 1 2 f = 1 2 3 f = 1 2 3 2 2 f = 1 2 3 2 2 5 f = 1 2 3 2 2 5 2 3 f = 1 2 3 2 2 5 2 3 7 f = 1 2 3 2 2 5 2 3 7 2 2 2 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 twos = 7 fives = 1 ct = 1

3   Pass
n = 27; ct_correct = 6; assert(isequal(powerTenInFactorial(n),ct_correct))

f = [] f = 1 f = 1 2 f = 1 2 3 f = 1 2 3 2 2 f = 1 2 3 2 2 5 f = 1 2 3 2 2 5 2 3 f = 1 2 3 2 2 5 2 3 7 f = 1 2 3 2 2 5 2 3 7 2 2 2 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Column 30 17 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 33 17 2 3 3 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 34 17 2 3 3 19 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 37 17 2 3 3 19 2 2 5 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 39 17 2 3 3 19 2 2 5 3 7 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 41 17 2 3 3 19 2 2 5 3 7 2 11 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 42 17 2 3 3 19 2 2 5 3 7 2 11 23 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 46 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 48 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 50 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 53 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 twos = 23 fives = 6 ct = 6

4   Pass
n = 626; ct_correct = 156; assert(isequal(powerTenInFactorial(n),ct_correct))

f = [] f = 1 f = 1 2 f = 1 2 3 f = 1 2 3 2 2 f = 1 2 3 2 2 5 f = 1 2 3 2 2 5 2 3 f = 1 2 3 2 2 5 2 3 7 f = 1 2 3 2 2 5 2 3 7 2 2 2 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Column 30 17 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 33 17 2 3 3 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 34 17 2 3 3 19 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 37 17 2 3 3 19 2 2 5 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 39 17 2 3 3 19 2 2 5 3 7 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 41 17 2 3 3 19 2 2 5 3 7 2 11 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 42 17 2 3 3 19 2 2 5 3 7 2 11 23 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 46 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 48 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 50 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 53 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 56 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 57 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 60 3 5 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 61 3 5 31 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 66 3 5 31 2 2 2 2 2 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 68 3 5 31 2 2 2 2 2 3 11 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 70 3 5 31 2 2 2 2 2 3 11 2 17 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 72 3 5 31 2 2 2 2 2 3 11 2 17 5 7 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 76 3 5 31 2 2 2 2 2 3 11 2 17 5 7 2 2 3 3 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 77 3 5 31 2 2 2 2 2 3 11 2 17 5 7 2 2 3 3 37 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 79 3 5 31 ...

5   Pass
n = 620; ct_correct = 152; assert(isequal(powerTenInFactorial(n),ct_correct))

f = [] f = 1 f = 1 2 f = 1 2 3 f = 1 2 3 2 2 f = 1 2 3 2 2 5 f = 1 2 3 2 2 5 2 3 f = 1 2 3 2 2 5 2 3 7 f = 1 2 3 2 2 5 2 3 7 2 2 2 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 f = 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Column 30 17 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 33 17 2 3 3 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 34 17 2 3 3 19 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 37 17 2 3 3 19 2 2 5 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 39 17 2 3 3 19 2 2 5 3 7 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 41 17 2 3 3 19 2 2 5 3 7 2 11 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 42 17 2 3 3 19 2 2 5 3 7 2 11 23 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 46 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 48 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 50 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 53 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 56 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 57 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 60 3 5 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 61 3 5 31 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 66 3 5 31 2 2 2 2 2 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 68 3 5 31 2 2 2 2 2 3 11 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 70 3 5 31 2 2 2 2 2 3 11 2 17 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 72 3 5 31 2 2 2 2 2 3 11 2 17 5 7 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 76 3 5 31 2 2 2 2 2 3 11 2 17 5 7 2 2 3 3 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 77 3 5 31 2 2 2 2 2 3 11 2 17 5 7 2 2 3 3 37 f = Columns 1 through 29 1 2 3 2 2 5 2 3 7 2 2 2 3 3 2 5 11 2 2 3 13 2 7 3 5 2 2 2 2 Columns 30 through 58 17 2 3 3 19 2 2 5 3 7 2 11 23 2 2 2 3 5 5 2 13 3 3 3 2 2 7 29 2 Columns 59 through 79 3 5 31 ...