Java Practice (a number is called the "finish" if it equals the sum of its factors.) Write the application and ask for all the numbers within 1000. )

Source: Internet
Author: User
/* (Start of Program head Note)
* Copyright and version Statement of the program
(c) 2011, the Computer College of Yantai University 
* All rights reserved.
* File name:                              
*    Person:   Shangpeng               
* Completion date:   year September 19
* Version number:      001    

* Description part of task and solution method
* Input Description: 
* Problem Description: If a number is exactly equal to the sum of its factors, this number is called the "end of the number." Write the application and ask for the number within 1000

.
* Program output: 
* Program Header comment End/
public


class demo01{

	/**
	 * @param args
	
		/public static void Main (string[] args) {
			
	
			int i,j;
			for (i = 1;i<=1000;i++) {
				int sum;
				Sum =0;
				for (j = 1;j<i;j++)
				{
					if (i%j ==0)
					{
						sum +=j;
					}
				}
					if (i = = sum)
						System.out.println ("" +i)
				
				
			;

		}

	}}

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.