I keep getting a notification that there is an infinite loop in my code...I'm not seeing it.

package com.codegym.task.task15.task1531;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
/*
Factorial
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int input = Integer.parseInt(reader.readLine());
reader.close();
System.out.println(factorial(input));
}
public static String factorial(int n) {
BigDecimal sum = new BigDecimal(1);
BigDecimal num = new BigDecimal(n);
if (n < 0) { return "0"; }
for (BigDecimal i = sum; i.compareTo(num) != 1; i.add(new BigDecimal(1))) {
sum = sum.multiply(i);
}
return sum.toString();
}
}

i = i.add(new BigDecimal(1))as the 3rd parameter of your for loop. Also, BigInteger is a better class to use for this task as decimals won't be needed.