4 kyu
Trailing zeros in factorials, in any given integer base
60 of 653Dr Phil
Description:
The factorial function is defined as follows:
0! = 1
n! = 1 * 2 * 3 * 4 * ... * n-2 * n-1 * n
Usually, the factorials of large numbers will have trailing zeroes. Your task is to create a function which returns the number of trailing zeroes of num!
in a given base
.
Here's two examples to get you started:
(num = 15, base = 10) => 3
# 15! = 1307674368000, which has 3 trailing 0's
(num = 7, base = 2) => 4
# 7! = 5040 = 0b1001110110000, which has 4 trailing 0's
Your code should be able to handle some very large numbers.
Note:
num
>= 0base
>= 2
HINT: Should you not make any headway after trying a long time, you should try this kata first.
Mathematics
Algorithms
Similar Kata:
Stats:
Created | Oct 20, 2014 |
Published | Oct 20, 2014 |
Warriors Trained | 8431 |
Total Skips | 685 |
Total Code Submissions | 9182 |
Total Times Completed | 653 |
Ruby Completions | 60 |
JavaScript Completions | 175 |
Python Completions | 397 |
Java Completions | 65 |
OCaml Completions | 7 |
Total Stars | 170 |
% of votes with a positive feedback rating | 93% of 131 |
Total "Very Satisfied" Votes | 117 |
Total "Somewhat Satisfied" Votes | 10 |
Total "Not Satisfied" Votes | 4 |
Total Rank Assessments | 9 |
Average Assessed Rank | 4 kyu |
Highest Assessed Rank | 2 kyu |
Lowest Assessed Rank | 5 kyu |