import java.util.Scanner; import java.util.ArrayList; import java.util.Collections; public class Main { public static ArrayList<Integer> list = new ArrayList<>(50); public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); scanner.close(); for (int i = 2; i < n; i++) { f(i); } } public static void f(int x) { int sum = 1; list.clear(); for(int i = 2; i <= Math.sqrt(x); i++) { if (x % i == 0) { sum += i + x / i; list.add(i); list.add(x / i); } } if (sum == x) { Collections.sort(list); System.out.print(x + " its factors are 1"); for(Integer e : list) { System.out.print(" " + e); } System.out.println(); } } }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题8.9 (C语言代码)浏览:570 |
矩形面积交 (Java代码)浏览:1222 |
C语言程序设计教程(第三版)课后习题8.2 (C语言代码)浏览:5232 |
C语言程序设计教程(第三版)课后习题9.2 (C语言代码)浏览:556 |
核桃的数量 (C语言代码)浏览:672 |
A+B for Input-Output Practice (VI) (C语言代码)浏览:558 |
小O的数字 (C语言代码)浏览:1411 |
1202题解浏览:631 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:646 |
C语言程序设计教程(第三版)课后习题8.2 (C++代码)浏览:661 |