Ramanujan sums (RS) and their Fourier transforms have attracted more and more attention in signal processing in recent years. Due to their non-periodic and non-uniform spectrum, RS are widely used in low-frequency noise processing, Doppler spectrum estimation and time-frequency analysis. However, the traditional method for calculating RS values is rather complex since it requires two numbers' factorization in two arithmetic functions. For a length-n vector, its Ramanujan-Fourier transform usually involves a series of RS values which will occupy O(n2) memory units. Thus, in this paper an approach based on prime-composition is proposed to reduce the complexity of RS calculation to O(n). Meanwhile, the complexity of Ramanujan-Fourier transform can be further reduced from O(n2) to O(n In(In(n))) .