05AB1E, n=13, 189 bytes
'Ì6×ÐI" ÿB`0¢ "D"₁h44₁44÷÷÷ÝÐÃм₁hhhÐÃ44u4÷÷÷₁h44₁44÷÷÷ǝ÷ƶê4₁÷÷ 1 Èÿ°À4ô¤¬ xÒÍÍ<_Zÿ11*Ò88w8*н¡Ë18*Ë xh`H°` ₂6₂6₂6$--«üuÆ-«üuÆ-«üuÆΘ ÒæP<<<<<<<<<<n(Zd XXšXXÜýвXšXš¥Æ≠≠ ÿÿð¨и0Ì<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
ÍÍ< # 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
<<<<<<<<<< # subtract 10 from each
n # square each
( # negate each
Z # maximum
d # is it >= 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Ì<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)
>>> ''.join(chr(i) for i in range(32,127,2))
' "$&(*,.02468:<>@BDFHJLNPRTVXZ\\^
bdfhjlnprtvxz|~'` so I can't evenprint
-- why don't I likerestricted-source
? ) \$\endgroup\$x
andn
but can be different values for differentn
\$\endgroup\$n
, since that it is where the crux of the challenge lies. Otherwise, the 1st program will probably often look likeif n==1 cat(program for n=1) else if n==2 cat(program for n=2) else if n==3...
\$\endgroup\$