describe
Perfect numbers, also known as perfect numbers or complete numbers, are some special natural numbers.
The sum of all its true factors (that is, divisors other than itself) (that is, the factor function) is exactly equal to itself.
For example: 28, it has divisors 1, 2, 4, 7, 14, 28. Except for 28 itself, the remaining five numbers are added together, 1+2+4+7+14=28.
Enter n, please output the number of perfect numbers within n (inclusive).
Data range: 1≤�≤5×105 1≤n≤5×105
Enter description:
Enter a number n
Output description:
Output the number of perfect numbers not exceeding n
Example 1
enter:
1000
Output:
3
Java:
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
while(in.hasNextInt()){
int n = in.nextInt();
//第一个完全数是6,若小于6则输出0
if(n < 6){
System.out.println(0);
continue;
}
int count