In article <1141149975.533951.14730
@t39g2000cwt.googlegroups.com>,
says...
> Hello,
> I'm taking an independant course in C++, and one of my questions asks
> to use the following algorithm to deturmine the factors of any given
> number:
> --
>
> Initialize a counter at 2
> So Long as long as the counter is less than or equal to the number
> if the counter divides the number evenly
> display the counter
> divide the number by the counter to get a new number
> else
> add one to the counter
>
> --
>
> I don't know exactly what "divide the number by the counter to get a
> new number" is asking.
Ignore programming for the moment, and think about how
you'd do this in your head. Assume, for example, that the
original number is 60. You start by seeing whether that
divides by 2. It does so you print out 2. You divide 60
by 2 to get 30. You check whether 30 divides by 2, and it
does as well. You print out 2 again, then divide 30 by 2
to get 15. You check whether 15 divides by 2, and it
doesn't. You increment your counter to 3 and start over
from the top -- 15 divides by 3, so you print out three,
and then divide 15 by 3 to get 5. 5 doesn't divide by
three, so you increment your counter to 4. 5 doesn't
divide by 4 so you increment your counter to 5. 5 divides
by 5 so you print out 5. You're now done.
--
Later,
Jerry.
The universe is a figment of its own imagination.