Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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

            }
        }
 
PREVIOUS NEXT
Tagged: #javaWrite #plan #prints #perfect #numbers #range
ADD COMMENT
Topic
Name
2+2 =