Haskell

——————————

` problem_27 = -(2*a-1)*(a^2-a+41)`

where n = 1000

m = head $ filter (\x -> x^2 - x + 41 > n) [1..]

a = m - 1

This is the “official” Haskell solution to Euler problem 27.

This solution is incomprehensible. The following hints are as far as I can get.

Prerequisite considerations:

`b`

must be a prime number, since `x^2 + a*x + b`

must be a prime number when `n=0`

.

` a = m - 1 `

is a choice of the prime number `b`

(in `x^2 + a*x + b`

) just(?) smaller than 1000.

a == 32

(\x -> x^2 – x + 41) 31 == 971

Why not the prime number 997?

— Me@2015.06.14 08:53 AM

It is because 997 is not a prime number generated by the formula `x^2 - x + 41`

.

— Me@2015-06-30 11:07:53 AM

`map (\x -> x^2 - x + 41) [0..40]`

is for generating 41 primes with the greatest Euler’s lucky number 41.

— Me@2015.06.14 08:34 AM

2015.07.01 Wednesday (c) All rights reserved by ACHK