Let z be a positive integer and let m be the number of nonzero terms in the base 2 expansion of z. Define /(z, s) as the number of positive integers rgz/2 such that the number of nonzero terms in the base 2 expansion of r plus the number of nonzero terms in the base 2 expansion of z-r is equal to m+s. We find formulas for f(z, s) and show how these formulas can be used in proving congruences for the Rayleigh function.