Program
24C++
K. Dzwonkiewicz
The factors of a
number that are less than that number are called the proper factors (all factors
besides the number).
In ancient Greece (500 BC), Pythagoras ran a school (PCMST)
for philosophy, science, mathematics, and cooking. His students were fanatical about learning. They became a cult that existed for 300
years. They thought everything in life
could be defined mathematically.
Harmony of a person’s life was calculated with a formula…all thongs were
measurable. In theory this may sound
plausible, but some things are just part of the ‘Aether’.
A DEFICIENT number is one whose proper factors sum to less than
the number.
(EX) 4 is deficient since proper factors added…1+2
= 3 < 4
An ABUNDANT number is one whose proper factors total more than
the number itself.
A PERFECT number is equal to the sum of its factors.
Write the program that will print the numbers 4 to 100 and their type,
in a nice little chart.
NUMBER SUM DEF ABUN PERF
4 3 X - -
5 1 X - -
6 6 - - X
7 1 X - -
8 7 X - -
9 4 X - -
10 8 X - -
Have the chart print out 20 numbers at a time, pause for a couple
seconds, clear screen, and continue.
Hint: Modify Program
22. Put an outside for
loop that goes like this…
for(
num=4 ; num<=100 ; ++num) //your
number loop
{
sum = 0;
for( y=1 ; y<(num/2) ; ++y) //your factor loop
}