判断一个整数能被几个9整除。
public static void main(String[] args) { f(729); f(730); } public static void f(int n) { int tmp = n; int count = 0; for (int i = 0; tmp % 9 == 0;) { tmp = tmp / 9; count++; } System.out.println(n + "能够被 " + count + "个9整除。"); }