1. 

package sem2.am.ilovebignumbers;

/**
* Angewandte Mathematik, SS11
* Problem: 10220 - I Love Big Numbers !
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1161
*
* @author Florian Stein
* @author Franz Sommer
* @version 1.0, 04/17/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.336
*/

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

public class Main {

public static void main(String[] args) throws IOException {
// input reader
Scanner scanner = new Scanner(System.in);

int number;

while (scanner.hasNext()) {
number = scanner.nextInt();

if (number == 0)
break;
if (number > 1000 || number < 0)
break;

BigInteger big = factorial(number);
// System.out.println(rest);
int tmp;
int sum = 0;
while (!big.equals(BigInteger.ZERO)) {
tmp = big.mod(BigInteger.TEN).intValue();
// System.out.println(tmp);
big = big.divide(BigInteger.TEN);
sum = sum + tmp;
}
if (number == 0) {
System.out.println("0");
} else {
System.out.println(sum);
}

// number++;
}

}

/**
* methode um fakultaet zu berechnen
*
* @param n
* @return
*/
public static BigInteger factorial(int n) {
if (n < 2) {
return BigInteger.ONE;
}
if (n == 2) {
return BigInteger.valueOf(2);
}
long k = (n + 1) >> 1;
BigInteger kk = BigInteger.valueOf(k * k);
BigInteger result = BigInteger.ONE;
for (int i = 1; i < k; i++) {
result = result.multiply(kk.subtract(BigInteger.valueOf(i * i)));
}
return result.multiply(n % 2 == 0 ? kk.shiftLeft(1) : BigInteger
.valueOf(k));
}
}

2.

/**
* Angewandte Mathematik, SS11
* Problem: 10220 - I Love Big Numbers !
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1161
*
* @author Benjamin Vogt
* @author Sebastian Stumpf
* @version 1.0, 16/04/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.268
*/

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


public class Main
{
public static void main(String[] args)
{
int n;
BigInteger big;
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
n = Integer.valueOf(s);

try
{
while(true)
{
big = fak(n);


if(n<=1000)
{
System.out.println(calculateSumOfDigits(big));
}

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;
}

private static long calculateSumOfDigits(BigInteger bigNumber)
{
char[] figures = bigNumber.toString().toCharArray();
long sumOfDigits = 0L;
for (int i = 0; i < figures.length; i++) {
char c = figures[i];
sumOfDigits += c - '0';
}
return sumOfDigits;
}
}

3.

/**
* Angewandte Mathematik, SS11
* Problem: 10220 I Love Big Numbers !
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1161
*
* @author Weber Christian
* @author Waldleitner Christoph
* @author Wolff Marco
* @version 1.0, 04/12/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.556
*/

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

public class ILoveBigNumbers
{

/**
* @param args
*/
public static void main(String[] args) throws Exception
{
Scanner scan = new Scanner(System.in);
String input = " ";
while(scan.hasNext())
{
input = scan.next();

if(input.equals("0"))
{
break;
}

BigInteger inte = new BigInteger(input);
BigInteger omg = new BigInteger("1");

for(BigInteger i = new BigInteger("2"); i.compareTo(inte) == -1 || i.compareTo(inte) == 0;i = i.add(new BigInteger("1")))
{
omg = omg.multiply(i);
}

BigInteger x = new BigInteger("0");

while(omg.compareTo(new BigInteger("0")) == 1)
{
BigInteger lulz = omg.mod(new BigInteger("10"));
x = x.add(lulz);
omg = omg.divide(new BigInteger("10"));
}

System.out.println(x);
}
System.exit(0);
}
}


4.

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

/**
* Angewandte Mathematik, SS11
* Problem: 10220 - I Love Big Numbers !
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=14&page=show_problem&problem=1161
*
* @author Unverzart Michael
* @author Wurth Manuel
* @version 1.0, 11/4/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.312
*/

public class Main {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String inputLine="";
while((inputLine = reader.readLine())!=null)
{
BigInteger erg = BigInteger.ZERO;
BigInteger cal[] = new BigInteger[2];
cal[0] = BigInteger.ONE;
int zahl = new Integer(inputLine);
for(int i=1 ; i <= zahl ; i++)
{
cal[0]=cal[0].multiply(BigInteger.valueOf(i));
}
do{
cal=cal[0].divideAndRemainder(BigInteger.valueOf(10));
erg=erg.add(cal[1]);
}while(cal[0].compareTo(BigInteger.ZERO)!=0);
System.out.println(erg);
}
}

}