Program compiling but not running in Eclipse

bignumbers
compile
eclipse
factorial
runtime

#1

I have some trouble with Eclipse I guess.
I want to run my factorial program and it compiles but doesn’t do anything else. Meaning no error message, no warning, etc…
Here is the code maybe you guys can tell me if the mistake is in the code or my eclipse needs some fix.
Or it is the big numbers?

import java.math.BigInteger;

public class FactorialTrailingZeros {

public static void main(String[] args) {
	
	int N = 60;
	System.out.println(factorial(N));
	System.out.println(getZeros(factorial(N)));

}
public static BigInteger factorial(int N){
	BigInteger fact = new BigInteger("1");
	for(BigInteger t = BigInteger.valueOf(1);
			t.compareTo(BigInteger.ZERO) <= N;
			t.add(BigInteger.ONE)){
		//bi1 = bi1.multiply(bi2);
		fact = fact.multiply(t);//multiply BigIntegers
	}
	return fact;
}
public static int getZeros(BigInteger C){
	int count = 0;
	while(C.mod(BigInteger.TEN) == BigInteger.ZERO){ //while the last digit is not different than 0 don't stop
		
		C = C.divide(BigInteger.TEN);				 //divide by 10 each time so we get a 10 times smaller number 100 -> 10
		
		count++;
	}
	return count;
}

}


#2

It is not the problem of eclipse. The for loop calculating factorial is the problem here. Change it to the following.

public static BigInteger factorial(int N){
    BigInteger fact = new BigInteger("1");
    BigInteger big_N=BigInteger.valueOf(N);
    for(BigInteger t = BigInteger.valueOf(1);
            t.compareTo(big_N) <= 0;
            t=t.add(BigInteger.ONE)){
        //bi1 = bi1.multiply(bi2);
        fact = fact.multiply(t);//multiply BigIntegers
    }
    return fact;
}

Your problem is in Comparable.

Given BigInteger x, y, the following are the comparison conditions:

x.compareTo(y) < 0 // x < y

x.compareTo(y) <= 0 // x <= y

x.compareTo(y) != 0 // x != y

x.compareTo(y) == 0 // x == y

x.compareTo(y) > 0 // x > y

x.compareTo(y) >= 0 // x >= y

This is not specific to BigInteger, this is applicable to any Comparable in general.

Note that the above is not the only way.

Read for loop syntax for BigInteger here.