I have a program to find the perfect number from 1 to n:How can this be reduced without changing it?class PerfectNumber{    public static StringBuffer fact(int a)    {         StringBuffer sb=new StringBuffer( );        for(int i=1;i<a;i++)        if(a%i==0)        {            sb.append(i+,);        }        return sb;     }    public static String isPrime(int a)    {        int sum=0;        for(int i=1;i<a;i++)        {            if(a%i==0)        {            sum+=i;        }           }        if (sum==a)        {            return true;        }        else            return false;    }    public static int perfecrNo(int a)    {        int sum=0;        for(int i=1;i<a;i++)        {            if(a%i==0)        {            sum+=i;        }           }        return sum;    }    public static void main(String[] args)    {        System.out.println(--------------------------------------------------------------------------);        System.out.printf(%s%40s%15s%15s%n,NO,fact,sum,isPrime);        System.out.println(--------------------------------------------------------------------------);        for(int i=1;i<100;i++)        {            System.out.printf(%n %d %40s\b %15d %15s,i,fact(i),perfecrNo(i),isPrime(i));        }    }}
Finding the perfect number from 1 to n
java