Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package uni.fmi.bacherlos;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- int n;
- int possibleFactor;
- int factorSum = 0;
- for (n = 2; n < 10000; n++) {
- factorSum = 0;
- for (possibleFactor = 1; possibleFactor <= n / 2; possibleFactor++) {
- if (n % possibleFactor == 0) {
- factorSum = possibleFactor + factorSum;
- }
- }
- if (factorSum == n) {
- System.out.println("" + n + " is a perfect number.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement