Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package loops;
- import java.util.Scanner;
- public class Loops {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int guess, sum = 0;
- System.out.print("Please enter a positive integer: ");
- guess = input.nextInt();
- while (working out condition still);
- {
- for(int i = 1; i < guess; i++)
- {
- if(guess % i == 0)
- {
- sum = sum + i;
- }
- }
- if(sum == guess)
- {
- System.out.println(guess + " is a perfect number.");
- }
- else if(sum < 0)
- {
- System.out.println(guess + " is not positive.");
- }
- else
- {
- System.out.println(guess + " is not a perfect number.");
- }
- }
- }
- int divisor(int x)
- {
- return x;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement