Found online one (of several) rule for divisibility by 13: https://byjus.com/maths/divisibility-rules-for-13/
Rule: For a given number, form alternating sums of blocks of three numbers from the right and move towards the left. Suppose n1n2n3n4n5n6…. is a number N, then if the number formed by the alternative sum and difference of blocks of 3-3 digits from right to left is divisible by 13, N is divisible by 13. Here, one should apply the subtraction first and then addition. See the example below to understand.
Example:
Check whether the 2,453,674 is divisible by 13.
Solution:
By applying Rule 1,
674 – 453 + 2 = 223 is not divisible by 13
Therefore, 2,453,674 also is not divisible by 13.
The 2023 6's at the end of the current problem can be considered to be in 337 groups of six 6's plus one left over, but the one left over should be considered at the left, next to the digit m. Each group of six is a pair of groups of three, and therefore cancel each other out by the above rule, and we're left with one 6, just to the right of the m.
Similarly there ae 2022 5's at the beginning, made up of self-cancelling groups of 6. That makes the 5m6, in the middle, the only non-cancelled group of 3, and it's a positive-counting one, and so the only one that counts.
Trial and error on the middle digit shows 546 is divisible by 13, and since numbers divisible by 13 are 13 apart, this would be the only one, so m = 4.
or, the easy way--do the actual brute-force search on the larger number, without reducing to a smaller number first:
n=[repmat('5',1,2023) 'm' repmat('6',1,2023)];
for mid='0':'9'
n(2024)=mid;
nval=sym(n);
if mod(nval,13)==0
disp(mid)
end
end
finds the missing digit is 4.