// A class that implements the Binomial Interface.
// By www.neiljohan.com
import java.util.StringTokenizer;
import java.io.*;

public class GetBiClass implements BinomialInterface
{
    int Coef;
    private static boolean debugging = true;

	/** @param tN & tK the values for working out the BinomialCoefficient
	 *  precondition tK>tN
	 *  @return Coef so that Coef>=1 or Coef=undefined */


    public GetBiClass(final int tN1, final int tK1) throws IOException
        {
            int tN=tN1;
            int tK=tK1;
            
                /* check pre-condition */
            if (debugging && (tN<tK)){
                System.out.println("Pre-condition violoated");
            }

            int tNumber=tN-1;

            for (int counter=0; counter<tK-1; counter++)
            {
                tN=tN*tNumber;
                tNumber--;
            }

            for (int count=tK; count>1; count--)
            {
                tK=tK*(count-1);
            }

            if (tK==0){
                Coef = 1;
            }
            else{
                Coef = tN/tK;
            }

//* check post-condition */
            if (debugging && (Coef<0)){
                System.out.println("Post-condition violoated");
            }
        }

    public int getBinomial()
        {
            return Coef;
        }


    public String toString()
        {
            return "GCD is" + Coef;
        }
}
