A duodecimal positive integer N consists of a string of sevens, that is, N = 77777.....7777 (base 12) such that N is divisible by the base 12 number 147.

Reading left to right, determine the last four duodecimal digits of the quotient.

For an extra challenge, solve this problem without using a computer program.

Note: I'm using base 10 up until the final answer.

The problem is equivalent to "Given N is an integer equal to (7/11)*(12^x-1) for some integer x and N is a multiple of 199, then find N mod 12^4."

199 is prime, so by Fermat's Little Theorem, 12^198 - 1 is a multiple of 199. Then x=198 makes N a multiple of 199. More concretely, we can write 7*(12^198 - 1) = 11*199*K for some integer K.

Then take both sides mod 12^4=20736. This simplifies the equation to 2189*K=20729 (mod 20736). This is just a regular linear congruence. Its primitive solution is K=9757.

Convert 9757 to base 12 to yield **5791**.