See USACO 1998 Spring Open, Problem 4, Subset Sums.

IMPORTANT NOTE REGARDING INPUT/OUTPUT FORMAT:

The input will consist of several test cases, each consisting of a single line containing an integer N. The input will be terminated by a line that contains the number 0 (which is not a test case).

For each line of input, output on a single line the number of partitions of {1,2,...,N}.