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

0

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

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);

            }
        }
Posted by: Guest on February-10-2022

Code answers related to "in javaWrite a plan that prints all the perfect numbers in the range of 1 to 1000"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language