## Day 280

### October 9, 2017

Pat Ballew is a retired math teacher who writes a blog *On This Day In Math* that gives a day-by-day history of mathematics. The blog is odd, quirky, and unquestionably fun. On October 7th, Ballew wrote:

The 280th day of the year…. The sum of the first 280 consecutive primes, mod 280, is prime.

Since I like to play with prime numbers, that got my attention, and I quickly went to determine how many such days there are in a year.

Your task is to determine how many days in a year share the characteristic that on the *n*th day the sum of the first *n* primes, mod *n*, is prime. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.

Pages: 1 2

Using the primes package for Haskell, the simple solution works just fine:

I went up to 367 to include leap years.

Perl ‘golf’ish solution – using a bit of bash and a bit of perl!

The bash in back ticks generates a list of 365 primes…

Get a list of 108 numbers – can add “|wc -w” to the end to get the number of values which satisfy this….

SML:

Here’s another Haskell solution, this one builds a list of the partial sums with scanl rather than recomputing each time around:

Using standard (R7RS) Scheme and popular a couple of popular libraries

(SRFI-1 and SLIB’s factor):

Klong 20170905

findPrimes@365

[5 6 7 8 12 15 16 19 20 21 24 26 30 34 37 38 40 42 44 45 46 48 49 50 55 58 59 60 62 64 65 66 67 68 70 72 73 75 76 78 86 87 88 92 102 116 120 122 124 128 130 132 135 140 143 145 150 156 158 164 165 166 168 172 173 175 176 182 183 191 196 210 214 216 218 223 234 236 241 248 250 256 259 262 265 266 272 280 285 301 306 310 311 314 315 324 328 330 336 337 344 347 348 349 352 355 358 365]