fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone
  7. {
  8. public static byte rightZeros(long n) {
  9. for (byte z = 0; ; z++, n /= 10) {
  10. if (n < 10 || n % 10 != 0) return z;
  11. }
  12. }
  13.  
  14. public static void main (String[] args) throws java.lang.Exception
  15. {
  16. System.out.println(rightZeros(123000L));
  17. System.out.println(rightZeros(102030L));
  18. System.out.println(rightZeros(123123L));
  19. System.out.println(rightZeros(10L));
  20. System.out.println(rightZeros(1L));
  21. System.out.println(rightZeros(0L));
  22. }
  23. }
Success #stdin #stdout 0.1s 320512KB
stdin
Standard input is empty
stdout
3
1
0
1
0
0