But a fixed size sieve is a big assumption that I'm not happy with. A pragmatic solution is to start with a sieve of length 10 and when that's not big enough, multiply the length by 10 and so on until we can find the answer.
This satisfies my inner software engineer but not my inner mathematician. I know I can't calculate the optimum size of sieve (if I could, I wouldn't need the sieve at all) but there must be some techniques for finding an upper bound.
In case an example is helpful, how about Euler 47? My top lever function looked like this. Posting any more would spoil the problem:
def findStreak(self, size): listLength = 10 while(True): factors = self.sieveForFactors(listLength) streakStart = self.findStreakInList(factors, size) if streakStart != -1: return streakStart listLength *= 10

New Topic/Question
Reply



MultiQuote







|