We will keep in mind the formula for integration by parts, which is:
int u dv = uv - int v du
To find this integral successfully we will let u = x, and dv = cos 5x dx. Therefore, du = dx and v = 1/5 sin 5x. (v can be found using a quick u-substitution)
The reason I chose x for the value of u is because I know that later on I will end up integrating v multiplied by u's derivative. Since the derivative of u is just 1, and since integrating a trig function by itself doesn't make it any more complex, we've effectively removed the x from the integrand and only have to worry about the sine now.
So, plugging into the IBP's formula, we get:
int xcos5x dx = (x sin5x) / 5 - int 1/5 sin 5x dx
Pulling the 1/5 out of the integrand gives us:
int xcos5x dx = (x sin5x) / 5 - 1/5 int sin 5x dx
Integrating the sine will only take a u-substitution. Since we've already used u for the IBP's formula I'll use the letter q instead:
q = 5x
dq = 5 dx
To get a 5 dx inside the integrand I'll multiply the integral by another 1/5:
int xcos5x dx = (x sin5x) / 5 - 1/25 int 5sin 5x dx
And, replacing everything in terms of q:
int xcos5x dx = (x sin5x) / 5 - 1/25 int sinq*dq
We know that the integral of sin is -cos, so we can finish this integral off easily. Remember the constant of integration:
int xcos5x dx = (x sin5x) / 5 + 1/25 cos q + C
Now we will simply substitute back q:
int xcos5x dx = (x sin5x) / 5 + (cos 5x) /25 + C
And there is our integral.