• + 0 comments

    My Python Loopless Solution

    With Derivation of Answer

    def solve(a, n, m):
    	digits = len(str(a))
    	divisor = 10**digits-1
    	m *= divisor
    	return (a % m)*(pow(10, digits*n, m)-1) % m // divisor
    

    Explanation