Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

4
Print combinations in ascending order of sum?
Post Body

I'm trying to write an algorithm (in Python, if that matters) that prints all the combinations of 5 prime numbers, but I want the first combination to have the lowest sum, the second combination to have the second lowest sum, etc. Is there a way to do this, or approximately do this?

I think the way to do this (broadly) is to find all the combinations for the set (p(1)... p(n)) (where p(n) is a prime), then adding p(n 1) to the set and finding the combinations that I didn't already find, then adding p(n 2) and doing the same thing. I'd really like a solution like this, actually, because I could use a generator function for the prime numbers, so I can just call prime.next() everytime I've exhausted all the possible combinations of n primes.

Thanks for the help, folks. Combinitorics makes my head spin, and any help would be appreciated.

Author
Account Strength
90%
Account Age
11 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,217
Link Karma
39
Comment Karma
1,178
Profile updated: 1 week ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
11 years ago