Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Enter a positive integer N
sample input
12
Sample Output
6
Example Description
divisor 12 comprises: 1,2,3,4,6,12. A total of six
problem-solving ideas:
The main question about the number of visits awareness of the relatively simple
code is as follows:
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int num = 0;
for (int i = 1; i <= n; i++) {
if(n%i==0){//判断是否可以除尽
num++;
}
}
System.out.println(num);
}
}