Created
October 28, 2018 03:57
-
-
Save ziggy192/b176ba6c80f85044d2737bf505297b50 to your computer and use it in GitHub Desktop.
Câu 1 đề thi vietai
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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