黑马程序员技术交流社区

标题: 小知识点 [打印本页]

作者: hexi5432    时间: 2016-8-8 21:47
标题: 小知识点
public class Demo04 {
        public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                System.out.println("Please input the number:");
                int n = sc.nextInt();
                System.out.print(n+"=");
                for (int i = 2; i <= n ; i++) {
                        while(i<n) {
                                if(n%i==0) {
                                        n=n/i;
                                        System.out.print(i);
                                        System.out.print("*");
                                       
                                }
                                else break;
                                
                        }
                        while(i==n){
                                System.out.print(i);
                                break;
                        }
                }
        }
}




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2