/*
2017年3月13日10:28:21
java基础50道经典练习题 例45
Athor: ZJY
Purpose:
【程序45】
题目:判断一个素数能被几个9整除
*/
import java.util.Scanner;
public class ProgramNo45_1
{
public static void main(String[] args) {
System.out.print("请输入一个数: ");
Scanner sc = new Scanner(System.in);
long number = sc.nextLong();
sc.close();
int count = 0;
long number_buf = number;
while (number_buf >= 9) {
number_buf /= 9;
count++;
}
System.out.println(number+"最多能被"+count+"个9除");
}
}
/*
2017年3月13日10:28:21
java基础50道经典练习题 例45
Athor: ZJY
Purpose:
*/
import java.util.Scanner;
public class ProgramNo45_2
{
public static void main(String[] args){
System.out.print("请输入一个数:");
Scanner scan = new Scanner(System.in);
long l = scan.nextLong();
long n = l;
scan.close();
int count = 0;
while(n > 8){
n /= 9;
count++;
}
System.out.println(l+"能被"+count+"个9整除。");
}
}