程序填空题:Perfect Numbers
A perfect number is a number that the sum of all factors (itself excluded) equals itself. For example, 6 is a perfect number because `1+2+3 = 6`.
This program reads two integers a and b, where `0
```Java
import java.util.stream.IntStream;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a = in.nextInt();
int b = in.nextInt();
int[] r =
IntStream.range(a, b).
filter( @@[x->IntStream.range(1,x).filter(k->x%k==0).sum()==x](5) ).
toArray();
for ( int x : r ) {
System.out.print(x+" ");
}
System.out.println();
in.close();
}
}
```
答案:
第1空:x->IntStream.range(1,x).filter(k->x%k==0).sum()==x
This program reads two integers a and b, where `0
```Java
import java.util.stream.IntStream;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a = in.nextInt();
int b = in.nextInt();
int[] r =
IntStream.range(a, b).
filter( @@[x->IntStream.range(1,x).filter(k->x%k==0).sum()==x](5) ).
toArray();
for ( int x : r ) {
System.out.print(x+" ");
}
System.out.println();
in.close();
}
}
```
答案:
第1空:x->IntStream.range(1,x).filter(k->x%k==0).sum()==x