Skip to content

Instantly share code, notes, and snippets.

@ziggy192
Created October 28, 2018 03:57
Show Gist options
  • Save ziggy192/b176ba6c80f85044d2737bf505297b50 to your computer and use it in GitHub Desktop.
Save ziggy192/b176ba6c80f85044d2737bf505297b50 to your computer and use it in GitHub Desktop.
Câu 1 đề thi vietai
import java.util.Scanner;
public class Cau1 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int input = scanner.nextInt();
System.out.println(checkPerfectNumber(input ));
}
public static boolean checkPerfectNumber(int number) {
//tim cac uoc
int sum = 0;
for (int i = 1; i < number; i++) {
if (number % i == 0) {
sum += i;
}
}
return sum == number;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment