Java强训day16(选择题编程题)
选择题
编程题
题目1
import java.util.Scanner;
public class Main {
public static boolean res(int m) {
int sum = 0;
for(int i=1;i<=m;i++) {
if(i!=m && m%i == 0) {
sum+=i;
}
}
if(sum == m)
return true;
else
return false;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = 0;
for(int i=1;i<=n;i++) {
if(res(i)) {
m++;
}
}
System.out.println(m);
sc.close();
}
}