判断一个整数能被几个9整除。
public class Example45 {
public static void main(String[] args) {
f(729);
}
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整除。");
}
}
原文:http://www.cnblogs.com/qubo520/p/6971472.html