Sunday, July 12, 2009

Pls help me! visual c++ code pls.. perfect number?

An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6 = 1 + 2 + 3. Write a C program perfect that determines if parameter number is a perfect number and determines and prints all the perfect numbers between 1 and 1000. Print the factors of each perfect number to confirm that the number is indeed perfect. Challenge the power of your computer by testing numbers much larger than 1000





this program code i need.. just %26lt;stdio.h%26gt;


it will be formula in program

Pls help me! visual c++ code pls.. perfect number?
how many times are you gonna ask this question? I already gave you a couple of huge hints, now try to do it yourself by using your brain... wow strange concept!
Reply:int tempSum;





for(int numbers=1;numbers%26lt;=1000;numbers++) {


tempSum=0;


for(int factors=1;factors%26lt;numbers;factors++) {


if((numbers%factors)==0){tempSum+=factor...


}


if(tempSum==numbers){printf("%i",%26amp;number...


}








the code needs little adjustments, but this is a good hint.


No comments:

Post a Comment