in javaWrite a plan that prints all the perfect numbers in the range of 1 to 1000

The solution for “in javaWrite a plan that prints all the perfect numbers in the range of 1 to 1000” can be found here. The following code will assist you in solving the problem.

for (int i = 2; i <= 1000; i++) {
            int sumodivs = 0;
            for (int j = 1; j < i; j++) {
                if (i % j == 0)
                    sumodivs += j;
            }//end of for
            if (sumodivs == i) {
                System.out.println(i);

            }
        }

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in