public class FattorialeWhile {

    /* n! = n * (n-1) * (n-2) * ... * 2 * 1
       valori interessanti: 12 (tutti ok)
                            13 (int con problemi)
                            17 (int con molti problemi)
                            20 (long ok)
                            21 (long con molti problemi)
                            23 (int e long hanno problemi?)
                            34 (int ha problemi serissimi)
                            66 (int e long hanno problemi serissimi)
                           171 (anche double non se la passa bene)
    */

    public static void main (String[] args) {
	System.out.print("Dammi un intero: ");
	int n = Input.readInt();

	int fatInt = 1;
	long fatLong = 1;
	double fatDouble = 1;

	int i = n;
	while (i > 1) {
	    fatInt = fatInt * i;
	    fatLong = fatLong * i;
	    fatDouble = fatDouble * i;
	    i = i - 1;
	}

	System.out.println ("Il fattoriale   (int)  di " + n + " e' " + fatInt);

	System.out.println ("Il fattoriale  (long)  di " + n + " e' " + fatLong);

	System.out.println ("Il fattoriale (double) di " + n + " e' " + fatDouble);

	System.out.println ();
   }
}
