1. 


/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem 324 Factorial Frequencies
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=260
*
* @author Miesel Christoph
* @author Seilbeck Robert
* @author Wolfram Andre
*
*
* Status : Accepted
* Runtime: 0.140
*/

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

public class Main {
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
int input = sc.nextInt();
while (input != 0) {
int factorial = input;
BigInteger value = new BigInteger(input + "");
input--;
for (; input >= 2; input--)
value= value.multiply(new BigInteger(input + ""));

String bigNumber = value.toString();
HashMap<String, Integer> numberCount = new HashMap<String, Integer>();
for (int p = 0; p < 10; p++)
numberCount.put(p + "", 0);

for (int k = 0; k < bigNumber.length(); k++) {
String chr = bigNumber.charAt(k) + "";
Integer count = numberCount.get(chr);
numberCount.put(chr, count + 1);

}
System.out.println(factorial + "! --");
System.out.printf("(%d) %s", 0, numberCount.get(0 + ""));
for (int i = 1; i < 5; i++) {
System.out.printf(" (%d) %s", i, numberCount.get(i + ""));
}
System.out.println();
System.out.printf("(%d) %s", 5, numberCount.get(5 + ""));
for (int i = 6; i < 10; i++) {
System.out.printf(" (%d) %s", i, numberCount.get(i + ""));
}
System.out.println();
input = sc.nextInt();
}
}
}

2.


/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem: Factorial Frequencies (324)
* @author Christian Mitterreiter
* @author Rolf Luigs
* @version 1.0, 05/31/2009
* Status : Accepted
* Runtime: 0.136
*/


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


public class Main{


static BigInteger fakultaet( int n ) { //Berechnung der Fakultšt

BigInteger big = BigInteger.ONE;

if ( n == 0 || n == 1 )
return big;

if ( n > 1 )
for ( int i = 1; i <= n; i++ )
big = big.multiply( BigInteger.valueOf(i) );

return big;
}



static public void main( String args[] ) {

Scanner sc = new Scanner(System.in);

int input = sc.nextInt();

while(input!=0) { //Abbruchbedingung

int[] countZiffern = new int[] {0,0,0,0,0,0,0,0,0,0};
String result = fakultaet(input) + "";

for(int i = 0; i<result.length();i++) { //Anzahl der jeweils vrokommenden Ziffern in ein Array abspeichern
countZiffern[result.charAt(i)-48]++;
}

//Ausgabe
System.out.println(input+"! --");
for(int i = 0; i<5;i++) {
System.out.printf("%s%5d"," "+"("+i+")", countZiffern[i]);
}

System.out.println();
for(int i = 5; i<10;i++) {
System.out.printf("%s%5d"," "+"("+i+")", countZiffern[i]);
}
System.out.println();

input = sc.nextInt();
}
}
}