Created
September 22, 2013 19:58
-
-
Save wszdwp/6663220 to your computer and use it in GitHub Desktop.
Cracking the interivew 19.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Question192 | |
{ | |
public static int numZeros(int num) { | |
int count = 0; | |
if (num < 0) { | |
return -1; | |
} | |
for(int i = 5; num / i > 0; i *= 5) { | |
count += num / i; | |
} | |
return count; | |
} | |
public static void main(String[] args) { | |
int num = 25; | |
System.out.println( "Expected(6): " + numZeros(num) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment