import java.io.*;

public class Facloop {
    
    public static void main( String[] args ) {
        BufferedReader in    
            = new BufferedReader( new InputStreamReader( System.in ) );
	
        while ( true ) {
            System.out.print( "Zahl eingeben (oder 'quit'): " );
            try {
                String eingabe = in.readLine();
                if ( eingabe.equals( "quit" ) ) break;
                int n = Integer.parseInt( eingabe );
                System.out.println( factorial( n ) );
            } catch ( Exception e ) {
                System.out.println( "Ungueltige Eingabe:\n\t" + e );
            }
        }
    }
    
    public static int factorial( int x ) {
        if ( x < 0 ) throw new IllegalArgumentException
                         ( "Argument darf nicht negativ sein!" );
        int result = 1;
        while ( x > 0 ) result *= x--;
        return result;
    }
}
