static int CountDigit5(int number) { int cnt = 0; while (number != 0) { int digit = number % 10; if (digit == 5) { cnt++; } number /= 10; } return cnt; } static int Ending5(int number) { int cnt = 0; while (number != 0) { int digit = number % 10; if (digit == 5) { cnt++; } else { break; } number /= 10; } return cnt; }