Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		N, K, S := io.NextInt(), io.NextInt(), io.NextInt()
		if N == 0 {
			break
		}
		dp := [21][11][156]int{}
		for i := 0; i <= N; i++ {
			dp[i][0][0] = 1
		}
		for i := 1; i <= N; i++ {
			for j := 1; j <= K; j++ {
				for k := 1; k <= S; k++ {
					if k-i >= 0 {
						dp[i][j][k] += dp[i-1][j-1][k-i]
					}
					dp[i][j][k] += dp[i-1][j][k]
				}
			}
		}
		io.Println(dp[N][K][S])
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include<iostream>
#include<vector>
#include<bitset>
#include<string.h>

using namespace std;

vector<int> ans;
const int max_dp = 1<<20;
int main(){
	while(true){
		int n,k,s;
		cin >> n >> k >> s;
		if(n == 0 && k == 0 && s == 0) break;
		
		int count = 0;
		for(int i = 0;i < (1<<n);i++){
			bitset<20> bs(i);
			int sum = 0;
			int used = 0;
			for(int j = 0;j < n;j++){
				if(bs[j]){
					sum += j+1;
					used++;
				}
			}
			if(used == k && sum == s) count++;
		}
		ans.push_back(count);
	}
	
	for(int i = 0;i < ans.size();i++){
		cout << ans[i] << endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
int n, k, s, ans;
int dp[11][155][21];
int solve(int deep = 0, int sum = 0, int back = 0) {
	if (deep == k) {
		return sum == s;
	}
	if (dp[deep][sum][back] >= 0)return dp[deep][sum][back];
	int res = 0;
	for (int i = back + 1; i <= n; i++) {
		res += solve(deep + 1, sum + i, i);
	}
	return dp[deep][sum][back]=res;
}
signed main() {
	while (cin >> n >> k >> s, n || k || s) {
		ans = 0;
		memset(dp, -1, sizeof(dp));
		cout << solve() << endl;

	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k, s;
  while (cin >> n >> k >> s, n) {
    if (k > n) {
      cout << "0\n";
      continue;
    }
    s -= k;
    vector<int> a(n);
    fill(end(a) - k, end(a), 1);
    int res = 0;
    do {
      int sum = 0;
      for (int i = 0; i < n; ++i) {
        if (a[i]) {
          sum += i;
        }
      }
      res += sum == s;
    } while (next_permutation(begin(a), end(a)));
    cout << res << '\n';
  }
}

C++: #include <iostream>
using namespace std;
int main() {
  int n, k, s, ans, t, u;
  while (cin >> n >> k >> s, n) {
    int A[k];
    for (int i = 0; i < k-1; ++i) A[i] = i+1;
    A[k-1] = s - k*(k-1)/2;
    ans = 0;
    t = k-2;
    while (A[k-1] > A[k-2]) {
      if (A[k-1] <= n) ++ans;
      ++A[t];
      --A[t+1];
      if (A[t] >= A[t+1]) {
	while (t > 0) {
	  --t;
	  ++A[t];
	  u = 0;
	  for (int i = 0; i <= t; ++i) u += A[i];
	  for (int i = t+1; i < k-1; ++i) {
	    A[i] = A[i-1]+1;
	    u += A[i];
	  }
	  A[k-1] = s - u;
	  if (A[k-1] > A[k-2]) {
	    t = k-2;
	    break;
	  }
	}
	if (!t) break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
int cnt;
int n, k, s;
void dfs(int add,int sum,int re) {
	if (k == re) {
		if (sum == s)
			cnt++;
		return;
	}
	for (int i = add + 1;i<=n;i++) {
		dfs(i, sum + i, re + 1);
	}
}
int main() {
	
	while (cin >> n >> k >> s, n){
		cnt = 0;
		dfs(0,0,0);
		cout << cnt << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------
int n,k,s;

int dfs(int prev,int pos,int sum)
{   
    int res=0;
    if(pos==k) return sum==s;
    for(int i=prev+1;i<=n;i++){
        res+=dfs(i,pos+1,sum+i);
    }
    return res;
}   

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(cin>>n>>k>>s,n){
        cout<<dfs(0,0,0)<<endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

int solve(int n,int k,int s){
	if(k==0) return s==0?1:0;
	if(n==0 or s<0) return 0;
	return solve(n-1,k,s)+solve(n-1,k-1,s-n);
}

int main(){
	int n,k,s;
	while(cin>>n>>k>>s,n){
		cout<<solve(n,k,s)<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int tbl[30][13][160];
int solve(int n,int k,int s){
  if(k==0 && s==0) return 1;
  if(k<0 || s<0) return 0;
  if(tbl[n][k][s]) return tbl[n][k][s];
  int ret = 0;
  for(int i=n;i>=1;--i){
    ret+=solve(i-1,k-1,s-i);
  }
  return tbl[n][k][s]=ret;
}
int main(){
  int n,k,s;

  while(cin>>n>>k>>s,n||k||s){
    cout << solve(n,k,s) << endl;
  }
  return 0;
}