local l, r, m = io.read("*n", "*n", "*n") if m <= l then print(0) os.exit() end if m <= r then r = m - 1 end local fact = {1} for i = 2, m - 1 do fact[i] = (fact[i - 1] * i) % m end local fact2 = {1} for i = 2, m - 1 do fact2[i] = (fact2[i - 1] * fact[i]) % m end local ans = 0 for i = l, r do ans = ans + fact2[i] end print(ans % m)