You need to divide the modulo product after all multiplication is done and
NOT in every loop.
private static int moduloProduct(int a, int b) {
int product = 1;
for (int i = 1; i <= a; i++) {
product = (product * i);
}
return product/b;
}
BTW: use better naming like and check the modulo for 0. It could crash without checke.
private static int moduloProduct(int producto, int modulo)