View Single Post
Old 2008-04-25, 22:02   #7
petrw1
1976 Toyota Corona years forever!
 
petrw1's Avatar
 
"Wayne"
Nov 2006
Saskatchewan, Canada

463310 Posts
Default

I would consider saving in an array all numbers (prime or otherwise) encountered so far. Whenever your current chain matches one of those you can skip to the next chain knowing it will eventually end in 3.

I suspect that most will abort a lot sooner.

I believe the astutue programmers call this memoization.
petrw1 is offline   Reply With Quote