1. Erste Version: C, Evgeni Pavlidis


/**
* ACM programming Contest WS 08/09
* UVa Status: accepted
* Run Time: 0.000
* see http://snippets.dzone.com/posts/show/5360
*/
#include <stdio.h>
#include <limits.h>


int main()
{

int n;
int k;

while(1)
{
scanf("%d %d\n", &n, &k);

if(n == 0 && k == 0)
return 0;


if(k == n || k == 0)
{
printf("1\n");
continue;
}

if(k > n/2)
k = n - k;

int i;

long long r = 1;

for( i=0; i<k; i++)
{
r = r * (n - i);
r = r / (1 + i);
}

printf("%d\n", r);


}


}


2. Zweite Version, Java, Evgeni Pavlidis

/***
?????
**/

import java.util.*;
import java.io.*;


class Main extends Thread {

private Scanner input = new Scanner(System.in);
private Map<Integer,Integer> primes = new TreeMap<Integer,Integer>();
private int primesMax = 2;

public static void main(String... args)
{
(new Main()).start();
}

public void run()
{
primes.put(2,0);
while(true)
processCase();
}

void processCase()
{
for(int i: primes.keySet())
primes.put(i,0);
Scanner scanner = input;
int n = scanner.nextInt();
int k = scanner.nextInt();
if(n == 0 && k==0)
System.exit(0);

generatePrimes(n);

for(int i = n; i > n-k; i--)
if(primes.containsKey(i))
if(primes.get(i) == null)
primes.put(i, 1);
else
primes.put(i, primes.get(i) + 1);
else
{
int part = i;
for(int prime: primes.keySet())
while( part % prime == 0 )
{
primes.put(prime, primes.get(prime) + 1);
part /= prime;
}
}


for(int i = k; i > 1; i--)
if(primes.containsKey(i))
primes.put(i,primes.get(i) - 1);
else
{
int part = i;
for(int prime: primes.keySet())
while( part % prime == 0 )
{
primes.put(prime, primes.get(prime) - 1);
part /= prime;
}
}



System.out.println(calcNumber());
}


int calcNumber()
{
int n = 1;
for(int prime: primes.keySet())
if(primes.get(prime) > 0)
n *= Math.pow(prime, primes.get(prime));

return n;
}

void generatePrimes(int limit)
{
if(limit > primesMax)
{
for(int i = primesMax + 1; i <= limit; i++)
if(isPrime(i))
primes.put(i,0);
primesMax = limit;
}
}

boolean isPrime(int n)
{
if(n <= primesMax)
if(primes.containsKey(n))
return true;
else
return false;


for(int i: primes.keySet())
if(i > Math.sqrt(n))
return true;
else
if(n % i == 0)
return false;

return true;
}

}

3. Java, Till Fischer

/*

 ============================================================================

 Name            : Main.java

 Author            : Till Fischer

 Description    : 530 - Binomial Showdown

 Accepted        : Accepted

 Time            : 0.100

 ============================================================================

 */





import java.io.BufferedReader;

import java.io.BufferedWriter;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.OutputStreamWriter;





public class Main {



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

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

        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

        String line;

        String[] splitted;

        long i, n, k, result;



        while(true) {

            line = reader.readLine();

            if(line.equals("0 0"))

                break;



            splitted = line.split(" ");

            n = Integer.parseInt(splitted[0]);

            k = Integer.parseInt(splitted[1]);



            if( k > n/2) {

                k = n - k;

            }

           

            result = 1;

            for(i = 0; i < k; i++) {

                result = result * (n - i);

                result = result / (i+1);

            }

            writer.write(result + "\n");

        }



        writer.flush();

        writer.close();

    }



}