1.

/**
* Angewandte Mathematik, SS11
* Problem: 623 - 500!
* Link:
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=8&page=show_prob
lem&problem=564
*
* @author Brielbeck, Daniel
* @author Weber, Georg
* @version 1.0, 03/29/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 1.960
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String input;
int n;
BigInteger zahl;
while ((input = reader.readLine()) !=null) {
input=input.split("!")[0];
n = Integer.valueOf(input);
zahl = new BigInteger("1");
for (int i = n; i > 1; i--) {
zahl = zahl.multiply(new BigInteger(String.valueOf(i)));
}
System.out.println(n+"!");
System.out.println(zahl);
}
}
}

2.


import java.math.BigInteger;
import java.util.Scanner;

/**
* Angewandte Mathematik, SS11
* Problem: 623 - 500!
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=8&page=show_problem&problem=564
*
* @author Benedikt Zšnnchen
* @author Erik Wenzel
* @version 1.0, 03/30/2011
*
* Method : Ad-Hoc, Vorberechnung, BigInteger
* Status : Accepted
* Runtime: 1.056
*/

public class Main
{
public static void main(String[] args)
{
BigInteger[] result = new BigInteger[1001];
result = generateFak(1000, result);
Scanner sc = new Scanner(System.in);
int number;

while(sc.hasNextInt())
{
number = sc.nextInt();
System.out.println(number+"!");
System.out.println(result[number]);
}
}

public static BigInteger[] generateFak(int n, BigInteger[] result)
{
result[0] = new BigInteger(1+"");
for(int i = 1; i <=n; i++)
{
result[i] = result[i-1].multiply(new BigInteger(""+i));
}
return result;
}

}

3.

/**
* Angewandte Mathematik, SS11
* Problem: 623 500!
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=8&problem=564
*
* @author Unverzart Michael
* @author Wurth Manuel
* @version 1.0, 29/3/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 1.932
*/

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main
{
public static void main(String args[]) throws Exception
{
int zahl=0;

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String inputLine="";
while((inputLine = reader.readLine())!=null)
{
BigInteger ergebnis= new BigInteger("1");
zahl = new Integer(inputLine);
for(int i=1 ; i <= zahl ; i++)
{
ergebnis=ergebnis.multiply(new BigInteger(Integer.toString(i)));
}
System.out.println(zahl+"!");
System.out.println(ergebnis);
}
}
}


4.





/**




 * Angewandte Mathematik, SS11




 * Problem: 623 500!






 *




 * @author Christopher Westerfield




 * @version 1.0, 03/20/2011




 *




 * Method : Ad-Hoc




 * Status : Accepted




 * Runtime: 0.100




 */




  




import java.io.BufferedReader;




import java.io.IOException;




import java.io.InputStreamReader;




import java.math.BigInteger;




   




class Main




{




    public static void main(String[] args) throws IOException{




        int[] input = new int[1];




        input[0] = -1;




        int i = 0;




        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));




        String line;




        while ((line = stdin.readLine()) != null && line.length()!= 0) {




            if(i<input.length){




                input = expand(input,5);




            }




            input[i] = Integer.parseInt(line);          




            i++;




        }




        calculate(input);




    }




    private static int[] expand(int[] old, int extend){




        int[] newInt = new int[old.length+extend];




        int i = 0;




        for(i = 0; i<old.length; i++){




            newInt[i] = old[i];




        }




        for( ;i<newInt.length;i++){




            newInt[i] = -1;




        }




        return newInt;




    }




    private static void calculate(int[] input){




        BigInteger res;




        for(int i=0; i<input.length; i++){




            if(input[i]==-1)




                break;




            if(input[i]==0){




                System.out.println(input[i]+"!");




                System.out.println(1);




            }




            res = BigInteger.ONE;




            for(int a=1;a<=input[i];a++)




                res=res.multiply( BigInteger.valueOf(a) );




            System.out.println(input[i]+"!");




            System.out.println(res);




        }




    }




}


5.

/**
* Angewandte Mathematik, SS11
* Problem: 623 - 500!
* Link: http://uva.onlinejudge.org/external/6/623.pdf
*
* @author Benjamin Vogt
* @author Sebastian Stumpf
* @version 1.0, 16/04/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 1.624
*/

import java.math.BigInteger;
import java.util.Scanner;


public class Main
{
public static void main(String[] args)
{
int n;
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
n = Integer.valueOf(s);
try
{
while(true)
{
if(n<=1000)
{
System.out.print(n);
System.out.println('!');
System.out.println(fak(n));
}
else
{
System.out.print(n);
System.out.println('!');
System.out.println(0);
}
s = sc.nextLine();
n = Integer.valueOf(s);
}
}
catch(Exception e)
{
System.exit(0);
}
}

static BigInteger fak(int n)
{
BigInteger big = BigInteger.ONE;
if(n == 1)
return big;
if(n>1)
{
for(int i = 1; i<=n;i++)
{
big = big.multiply(BigInteger.valueOf(i) );
}
}
return big;
}
}


6.

/**
* Angewandte Mathematik, SS11
* Problem: 623 - 500!
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=8&page=show_problem&problem=564
* @author Fabian, Trampusch
* @author Robert Schwarz
* @version 1.0, 19.04.2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 1.536
*/


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;


public class Main {

public static void main(String[] args) throws IOException {
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while (true) {
int input = Integer.parseInt(reader.readLine());

BigInteger result = BigInteger.ONE;
for(int i = 1; i <= input; i++) {
result = result.multiply(BigInteger.valueOf(i));
}

System.out.println(input+"!");
System.out.println(result.toString());
}
}catch(Exception e){}
}
}


--------------------------------------------------------------------------------------------
1.

/*
* ACM Contest training
* Problem: 623 - 500!
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=8&page=show_problem&problem=564
*
* @author Christoph Goettschkes
* @version 1.0, 10/24/2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.980
*/


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.math.BigInteger;

class Main
{

public static List<BigInteger> l = new ArrayList<BigInteger>();

public static void main(String[] args) throws Exception
{
calc();

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line = reader.readLine();

while (true)
{
int n = Integer.parseInt(line);
System.out.println(n + "!");
System.out.println(l.get(n));

if (!reader.ready())
break;
line = reader.readLine();
}

}

public static void calc() {
int i = 1;
BigInteger cur = new BigInteger("1");
l.add(new BigInteger("1"));
while (i <= 1000) {
l.add(cur);
cur = cur.multiply(new BigInteger(i+1+""));
i++;
}
}
}