"Program 19"
Title: If a number is exactly equal to the sum of its factors, this number is called the "end number". For example, 6=1+2+3. Programming to find all the finished numbers within 1000.
1. Program Analysis: All the factors plus the number of comparisons.
2. Program Source code:
1 /*this article transferred from blog: www.cnblogs.com/java-1002 "program 19"3 title: If a number is exactly equal to the sum of its factors, this number is called the "end number". For example 6=1+2+3, programming to find out all the numbers within 1000. 4 Program Analysis: All the factors plus the number of comparisons. 5 */6 7 Public classJava19 {8 9 Public Static voidMain (string[] args) {Ten for(inti = 2; i < 1000; i++) { One intsum = 0; A for(intj = 1; J < I; J + +) { - if(i% j = 0) { -Sum + =J; the } - } - if(Sum = =i) { -System.out.print (i + "")); + } - } + } A}
Java rewrite "C Classic 100 Questions"--19