include <stdio.h>
#define MAXN 200
/**
-
A function that counts the number of ways that
-
represent 'n' only as natural numbers less than or equal to 'm' */ int partition_memo(int n, int m) { static int memo[MAXN][MAXN]; // use memoization int count = 0, i;
if(n < m) m = n; if(memo[n][m] > 0) return memo[n][m]; if(n == 0) return memo[n][m] = 1;
for(i = 1; i <= m; i++) count += partition_memo(n - i, i); return memo[n][m] = count; }
int main(int argc, char** argv) { printf("%d\n", partition_memo(20, 10)); return 0; }