Could They Be The Same Day Of The Week?

Python 2, 58 bytes

u=-abs(200-input()%400)-4
print u/100+5>(u-8)*5/4%7>u%4/-3

Try it online!

A direct formula.


Jelly, 20 18 bytes

99R4ḍj`‘ṡ%4ȷ$S€P7ḍ

Outputs 1 for members, 0 for non-members.

Try it online!

How it works

99R4ḍj`‘ṡ%4ȷ$S€P7ḍ  Main link. Argument: n

99                  Set the return value to 99.
  R                 Range; yield [01, .., 99].
   4ḍ               Test each element in the range for divisibility by 4.
     j`             Join the resulting array, using itself as separator.
                    The result is an array of 9801 Booleans indicating whether the
                    years they represent have leap days.
       ‘            Increment the results, yielding 1 = 365 (mod 7) for non-leap
                    years, 2 = 366 (mod 7) for leap years.
         %4ȷ$       Compute n % 4000.
        ṡ           Take all slices of length n % 4000 of the result to the left.
             S€     Take the sum of each slice.
               P    Take the product of the sums.
                7ḍ  Test for divisibility by 7.

MATL, 17 bytes

`0Gv@+5:YcYO8XOda

The program halts if the input belongs to the sequence, or runs indefinitely (infinite loop) otherwise.

Let n be the input. The code executes a loop that tests years 1 and 1+n; then 2 and 2+n; ... until a matching day of the week is found. If no matching exists the loop runs indefinitely.

The membership function for n is periodic with period 400. Therefore, at most 400 iterations are needed if n belongs to the sequence. This requires less than 20 seconds in Try It Online. As a proof of this upper bound, here's a modified program that limits the number of iterations to 400 (by adding @401<* at the end). Note also that this bound is loose, and a few seconds usually suffice.

Try it online!

Explanation

`           % Do...while
  0Gv       %   Push column vector [0; n], where n is the input number
  @+        %   Add k, element-wise. Gives [k; k+n]
  5:        %   Push row vector [1, 2, 3, 4, 5]
  Yc        %   Horizontal "string" concatenation: gives the 2×6 matrix
            %   [k, 1, 2, 3, 4, 5; k+n, 1, 2, 3, 4, 5]. The 6 columns
            %   represent year, month, day, hour, minute, second
  YO        %   Convert each row to serial date number. Gives a column
            %   vector of length 2
  8XO       %   Convert each date number to date string with format 8,
            %   which is weekday in three letters ('Mon', 'Tue', etc).
            %   This gives a 2×3 char matrix such as ['Wed';'Fri']
  d         %   Difference (of codepoints) along each column. Gives a
            %   row vector of length 3
  a         %   True if some element is nonzero, or false otherwise
            % End (implicit). The loop proceeds with the next iteration
            % if the top of the stack is true

Old version, 24 bytes

400:"0G&v@+5:YcYO8XOdavA

Output is 0 if the input belongs to the sequence, or 1 otherwise.

Try it online!

Explanation

400         % Push row vector [1, 2, ..., 400]
"           % For each k in that array
  0G&v      %   Push column vector [0; n], where n is the input number
  @+        %   Add k, element-wise. Gives [k; k+n]
  5:        %   Push row vector [1, 2, 3, 4, 5]
  Yc        %   Horizontal "string" concatenation: gives the 2×6 matrix
            %   [k, 1, 2, 3, 4, 5; k+n, 1, 2, 3, 4, 5]. The 6 columns
            %   represent year, month, day, hour, minute, second
  YO        %   Convert each row to serial date number. Gives a column
            %   vector of length 2
  8XO       %   Convert each date number to date string with format 8,
            %   which is weekday in three letters ('Mon', 'Tue', etc).
            %   This gives a 2×3 char matrix such as ['Wed';'Fri']
  d         %   Difference (of codepoints) along each column. Gives a
            %   row vector of length 3
  a         %   True if some element is nonzero, or false otherwise
  v         %   Concatenate vertically with previous results
  A         %   True if all results so far are true
            % End (implicit). Display (implicit)