We have defined temperature on the absolute scale such that the temperature of the source of a reversible Carnot heat engine is proportional to the heat taken in by the engine during its isothermal expansion at the hot temperature, and the temperature of the sink is proportional to the heat lost by the engine during its isothermal compression at the cool temperature. No heat is gained or lost, of course, during the adiabatic phases, and there is no change in internal energy over a complete cycle. Therefore Q1/Q2 = T1/T2.
Now, any cycle can be represented by an infinite number of infinitesimally narrow Carnot cycles operating in tandem. Thus ∫dQ/T during that part of the cycle in which an engine is losing heat is equal to ∫dQ/T during that part of the cycle in which it is absorbing heat. Therefore, during the complete cycle, ∫dQ/T is zero. This means that the net change in entropy during a complete cycle is zero, so that entropy is a function of state. In effect 1/T is an integrating factor which, when it multiplies the inexact differential đQ, results in the exact differential đQ/T = dS.