26 lines
540 B
Java
26 lines
540 B
Java
package LanQiaoOJ;
|
||
/*约数
|
||
* 题目描述
|
||
本题为填空题,只需要算出结果后,在代码中使用输出语句将所填结果输出即可。
|
||
如果整数 a是整数 b的整数倍,则称 b是 a的约数。
|
||
请问,有多少个正整数是 2020的约数。*/
|
||
public class 约数 {
|
||
public static void main(String[] args) {
|
||
int count=0;//表示2020的约数的个数
|
||
for(int a=1;a<=2020;a++) {
|
||
if(2020%a==0) {
|
||
count++;
|
||
}
|
||
}
|
||
System.out.println(count);
|
||
}
|
||
}
|
||
/*
|
||
* 法二
|
||
* int a=1;
|
||
* while(a<=2020){
|
||
if(2020%a==0)
|
||
count++;
|
||
a++;
|
||
}
|
||
*/ |