C/O logging is a main logging method that can determine oil saturation. The oil saturation of initial formation can be determined by C/O according to the inelastic gamma spectroscopy in LWD (logging while drilling). The inelastic gamma spectrum were simulated using the Monte Carlo method under the condition of different lithology, porosity, saturation, borehole size, mud and mud invasion, water salinity, shale content, hydrocarbon and source-receiver spacing in horizontal wells. The response of C/O and porosity and saturation was studied, and the effects of several factors on C/O values were given. It is favorable to identify formation fluid by using C/O spectroscopy logging under the condition of small mud invasion depth, small borehole size, high porosity and heavy oil.