In this paper, we present a simple and fast method for counting the number of nonnegative integer solutions to the equality a1x1+a2x2+: : :+arxr = n where a1; a2; :::; ar and n are positive integers. As an application, we use the method for finding the number of solutions of a Diophantine inequality