[Java]
/*
* Start the program header annotation.
* Copyright and version Declaration of the program
* Copyright (c) 2011, a student from the computer College of Yantai University
* All rights reserved.
* File name: calculate the number of all daffodils within 1000
* Author: Xue Guangchen
* Completion date: January 1, September 15, 2011
* Version No.: x1.0
* Description of tasks and Solutions
* Input description:
* Problem description: Calculate all full numbers within 1000.
This program is an Application. The so-called full number is the sum of a number exactly equal to its factors.
For example, 6 is a factor of 1, 2, 3, and 6 is 1 + 2 + 3, so 6 is a complete number.
* Program output:
* End the comment in the program Header
*/
Package xue.com;
Public class PerfectNumber {
/**
* @ Param args
*/
Public static void main (String [] args ){
// TODO Auto-generated method stub
System. out. println ("exact number :");
For (int I = 1; I <= 1000; I ++)
{
Int sum = 0;
For (int j = 1; j <I; j ++)
{
If (I % j = 0)
{
Sum = sum + j;
}
}
If (sum = I)
{
System. out. print (I + "");
}
}
}
}
Running result: