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.
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.
Subreddit
Post Details
- Posted
- 11 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/algorithms/...