/*
*ProgramCopyright and version declaration Section
* Copyright (c) 2011, a student from the computer College of Yantai University
* All Rights Reserved.
* File Name:
* Author: Zhang chuanxin
* Completion date: January 1, September 22, 2012
* Version No.: j.1.04
* Description of tasks and Solutions
* Input description:
* Problem description: if a natural number is used, the sum of all its true factors (that is, an approximate number other than itself) exactly equals to itself. This number is called a complete number. Summary"
For example,
6 = 1 + 2 + 3
28 = 1 + 2 + 4 + 7 + 14
496 = 1 + 2 + 4 + 8 + 16 + 31 + 62 + 124 + 248
8128 = 1 + 2 + 4 + 8 + 16 + 32 + 64 + 127 + 254 + 508 + 1016 + 2032 + 4064
* Program output:Write a Java program to output all the complete numbers between any numbers.
* Problem Analysis: to calculate the number of input records of a number, the sum of the divisor values of this number must be equal to itself.
*AlgorithmDESIGN: first define the function to calculate the approximate number of the desired number, then add the approximate number, and compare it with itself to determine the result...
*/
Public class testcomnum {/*** @ Param ARGs */public static void main (string [] ARGs) {// todo auto-generated method stubprintcomnum (1000 );} static void printcomnum (int n) {for (INT I = 1; I <= N; I ++) {int S = 0; For (Int J = 1; j <I; j ++) {if (I % J = 0) {S = S + J ;}} if (S = I) {system. out. println (I + "is a full number... ");}}}}
Running result:
6 is the full number...
28 is a full number...
496 is a full number...
Experience Accumulation: from now on, develop good habits and don't be busy typingCodeIt is more important to analyze problems and build a framework !!!