Finding the factors of an integer

来源:互联网 发布:常用的网络通信协议 编辑:程序博客网 时间:2024/05/20 09:23
代码:import java.util.Scanner;public class Ten_six {public static void main(String[] args) {System.out.println("Enter an int value: ");Scanner cin = new Scanner(System.in);int a = 2, x;double num = 1;x = cin.nextInt();while (a<=x) {while (x % a == 0) {x = x / a;System.out.print(+a);System.out.print(" ");}a++;}}}运行结果:


 

0 0
原创粉丝点击