Gecko
Carpal \'Tunnel

Reged: 06/01/04
Posts: 14744
Loc: Third rock from the sun
|
|
Does anyone know how to design an algorithm for finding all the factors of a positive integer?
PS - In this case, CS stands for Computer Science
-------------------- If you air your dirty linen in public, expect people to comment on the skid marks!
|
elliesmom
Carpal \'Tunnel

Reged: 11/07/05
Posts: 5447
Loc: Virginia
|
|
Its been about 10 years since i set foot in a CS class, but here is my best guess.
First you'd probably have to set N= the integer in question. Then divide it by n-1, but first determine if n-1 is >0 (if no then stop) and then determine if answer is an integer if it is, then you will want to display n-1 as a factor or somehow save it into a number set. Then set n= n-1 and repeat.
-------------------- "I don't like piñatas. I think they promote violence against flamboyant animals."
|
Gecko
Carpal \'Tunnel

Reged: 06/01/04
Posts: 14744
Loc: Third rock from the sun
|
|
That makes a little more sense than some of the answers I got going through Google. Thanks.
-------------------- If you air your dirty linen in public, expect people to comment on the skid marks!
|