On 29/09/2022 17.54, Mike Terry wrote:
> On 29/09/2022 22:37, Michael F. Stemper wrote:
>> In problem 27 at Project Euler <
https://projecteuler.net/problem=27>,
>> the challenge is to provide a quadratic expression that generates
>> primes.
>>
>> In ordinary usage, a prime is positive. However, in algebraic number
>> theory, you can have primes over Z, which can be negative.
>>
>> Does anybody know which usage is intended in this problem?
>>
>
> It seems to me that the wording implies/suggests negative primes are ok.
>
> The wording says:
>
> n^2 + an + b must be prime for (a run of n starting at) n=0
> |b| <= 1000
> ...
>
> so by implication b < 0 is allowed, and for n=0, (n^2 + an + b) = b.
I was going to use that fact to further constrain b to 2<=b<998. But,
then I remembered the idea of "primes over Z".
> If primes had to be positive, why say |b| <= 1000, rather than 0 < b < 1000? That would just be unnecessarily deceptive wording IMO.
Well, I was thinking along those lines, but had the more
charitable interpretation of "loose wording". But, I guess
that I'll limit b to 1<|b|<998, which isn't much of a constraint.
> Anyway, this looks like a trivial problem to just brute force (around 4 million cases to check),
So far, I've only used brute force on Problem 20. Checking each
case does, of course, require evaluating the expression multiple
times. (How many, I don't know yet.)
> whereas other projecteuler problems I've looked at involve some
level of maths insight to achieve a solution in a reasonable computation time.
And I did Problem 25 without writing any program at all. My
approach to these has been to start off, not writing python,
but TeX. I apply as much math as I can, and use what I get to
design my code.
> Perhaps I'm not seeing something! :)
My need for an elegant solution.
Thanks for the follow-up.
--
Michael F. Stemper
Psalm 82:3-4