given a positive integer n, list all the combinations of the set {1,2,3,...,n}

Sorry, but we don't do your homework for you. First, you don't mention the programming language you are going to use - even if only pseudo-code or ANL if this is an abstract exercise. Second, you don't show any of your work for us to help correct and/or critique.

This should be catagorized in Computer Science. What I can tell you is what your looking for is the power set (the set of all subsets).

One hint I'll give you is that building the powerset is exactly the same as traversing a binary tree. Each element can exist or not exist in the subset.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.