import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        //System.out.println("Hello world!");
        
        /*Problem Description

      Q1:  Take an integer N as input and print the count of its factors.
        The factor of a number is the number that divides it perfectly leaving no remainder.

        Example: 1, 2, 3, and 6 are factors of 6*/
        
        
        /*Scanner scn = new Scanner(System.in);
        int N = scn.nextInt();
        int count = 0;
        System.out.println("Below given numbers are the factors of the given Number: N"  );
        for(int i=1;i<=N;i++){
            if(N%i==0){
                count++;
                System.out.print(i+ "," + " ");
            }
            
        }
            System.out.println(" ");
            System.out.print("The Total count of Factors of Number:" + N + " is: " + count);*/
            
        // Problem Description
        //Q2. Is It Perfect?
            
                Scanner scn = new Scanner(System.in);
                int T = scn.nextInt();
    
    
                    for(int i=1;i<=T;i++){
                    int N = scn.nextInt();
                    int sum = 0;
            
                    for(int j=1;j<N;j++){
                    if(N%j==0){
                    sum = sum + j;
                        }
                    }
                    if(N==sum){
                    System.out.println("YES");
                    }
                    else {
                    System.out.println("NO");
                }
            }


        }
    
    }

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: