How divisible are you? You are to create a program which, when given a positive integer \$n\$, outputs a second program. This second program, when run, must take a second positive integer \$x\$ and output one of two distinct values depending on whether \$x\$ is divisible by \$n\$. Those values must be consistent for a given \$n\$ but can be different values for different \$n\$.

However, for each value of \$n\$, the outputted program may only contain bytes whose code points are divisible by \$n\$. You may use any pre-existing code page to score and restrict your answer, but the code pages used for both programs must be the same. In addition, both programs must be in the same language (including versions. Python 3 \$\ne\$ Python 2). Your score is the highest consecutive value of \$n\$ your program works for. That is, your program must work for \$n = 1, 2, 3\$ and \$4\$ in order to have a score of \$4\$. All solutions must work for \$n = 1\$ and \$n = 2\$ at a minimum. The program with the highest \$n\$ wins.
05AB1E, n=13, 189 bytes

'Ì6×ÐI" ÿB`0¢ "D"₁h44₁44÷÷÷ÝÐÃм₁hhhÐÃ44u4÷÷÷₁h44₁44÷÷÷ǝ÷ƶê4₁÷÷ 1 Èÿ°À4ô¤¬ xÒÍÍ&lt;_Zÿ11*Ò88w8*н¡Ë18*Ë xh`H°` ₂6₂6₂6$--«üuÆ-«üuÆ-«üuÆΘ ÒæP&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;n(Zd XXšXXÜýвXšXš¥Æ≠≠ ÿÿð¨и0Ì&lt;0ǝÀ0ÿäÀ`∍`Ā"#Iè


Try it online! or validate codepoint divisibility.

n=1: 1 simply returns 1, since all integers are divisible by 1.

n=2: È is the built-in for that, and its codepoint is even.

n=3 TIO:

3B        # convert input to base 3
  `       # get the last digit
   0¢     # count occurences of 0 in that digit


n=4 TIO:

°         # 10**input
 À        # rotate left
  4ô      # split in chunks of 4 digits
    ¤     # get the last chunk
     ¬    # get the first digit of that chunk


n=5 TIO:

x         # double the input
 Ò        # prime factorization
  ÍÍ&lt;     # subtract 5 from each prime
     _    # equal to 0?
      Z   # maximum


n=6 works identically to n=3.

n=7 TIO:

11*               # multiply the input by 11
   Ò              # prime factorization
    88w8*н        # first digit of 88*8, namely 7
          ¡       # split the prime factorization on 7
           Ë      # are all sublists equal?
            18*   # multiply by 18
               Ë  # are all digits equal?


n=8 TIO:

x         # double the input
 h        # convert to hex
  `       # get the last digit
   H      # convert from hex
    °     # 10**x
     `    # get the last digit


n=9 TIO:

₂           # push 26
 6          # push 6
  $         # push 1 and input
   -        # subtract: 1 - input
    -       # subtract: 6 - (1 - input) = 5 + input
     «      # concatenate: "26" + (5 + input)
      üu    # for each pair of digit, uppercase the second one
            # (used to convert to a list of digits, but drops the first digit)
        Æ   # reduce by subtraction: 6 - sum(digits(5 + input))
            # the above sequence is repeated twice, yielding 6 - sum(digits(sum(digits(sum(digits(5 + input))))))
         Θ  # is it equal to 1?


Note that this algorithm doesn’t work for arbitrary large numbers (but it still works up to 10^10000000000, which is good enough).

n=10 TIO:

Ò                  # prime factorization of the input
 æ                 # power set
  P                # product of each subset
   &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;      # subtract 10 from each
             n     # square each
              (    # negate each
               Z   # maximum
                d  # is it &gt;= 0?


Divisibility by 10 is usually the easiest, but unfortunately there’s no compliant way to get the last digit.

n=11 TIO:

X                  # push 1
 Xš                # prepend 1: [1, 1]
   XXÜ             # 1, with trailing 1s trimmed off (aka empty string)
      ý            # join: 11
       в           # convert input to base 11
        Xš         # prepend 1
          Xš       # prepend 1
            ¥      # deltas
             Æ     # reduce by subtraction
              ≠≠   # is it equal to 1?


n=12 TIO:

ÌÌÌÌÌÌÌÌÌÌÌÌ           # add 24 to the input
 ð                     # space character        
  ¨                    # drop the last character (empty string)
   и                   # make a list of input empty strings
    0Ì&lt;0ǝ              # replace the first element with 1
     À                 # rotate left
      0ÌÌÌÌÌÌä         # split in 12 parts of approximately equal length
                       # (if the input isn’t divisible by 12, the first sublists will be longer)
       À               # rotate left
        `              # dump all to the stack
         ∍             # cycle the before-last sublist to match the length of the last sublist
          `            # get the last element
           Ā           # truthify


n=13 ([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]): TIO

₁h44₁44÷÷÷               # hex(256) / (44 / (256 / 44)) = 12
 Ý                       # range [0..12]
  ÐÃ                     # duplicate (well, triplicate then pop the third copy)
    м                    # remove (leaves a list of 13 empty strings)
     ₁hhhÐÃ44u4÷÷÷       # 13
      ₁h44₁44÷÷÷         # 12
       ǝ                 # set the element at index 12 to 13
        ÷                # integer division
                         # dividing by the empty string yields the numerator,
                         # so the result is 12x the input, followed by input / 13
         ƶ               # multiply each element by its index
                         # the last element is now equal to input iff 13 divides input
          ê              # sorted uniquify
           4₁÷÷          # divide by 0 (sets all elements to 0)