Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int input;
- int sum = 0;
- int sumSum = 0;
- int difference;
- System.out.println("AbundantNumbers: ");
- System.out.print("Enter a number: ");
- input = console.nextInt();
- if(input <= 0)
- {
- System.out.println("Invalid Input: ");
- }
- else
- {
- for(int x = 1; x <= input; x++)
- {
- if(input % x == 0)
- sum = sum + x;
- }
- sumSum = input*2;
- if(sum < sumSum)
- {
- System.out.println("It is not an abundant number: ");
- }
- else
- {
- if(sum > sumSum)
- {
- difference = sum - sumSum;
- System.out.println("It is an abundant number: ");
- System.out.println("the abundant is " + difference);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement