Thread: Prime numbers
View Single Post
  #7 (permalink)  
Old 05-12-2008, 11:48 AM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Mod
 
Join Date: Jul 2006
Age: 35
Posts: 1,751
Last Blog:
Game software (GURPS)
Rep Power: 24
WingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to all
Default 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.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall

Last edited by WingedPanther; 05-12-2008 at 11:49 AM. Reason: add note
Reply With Quote