Re: Prime numbers
dvdtomkins:
your code seems a little inefficient. I would run through the loop once, building the factors into a string. If the string is empty, output "prime", otherwise output the factors with 1 and n added to the list. This would also make your loop shorter, as you could loop from 2 to n/2.
Also, please use code tags in the future.
Last edited by WingedPanther; 05-12-2008 at 11:49 AM.
Reason: add note
|