Java rewrite "C Classic 100 Questions"--19

Source: Internet
Author: User

"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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.