Linux questions, math questions

One point for each:

Math Question

The initial question is “how many different sets of size M can you get from a sack containing N items?”

That’s N choose M which is exactly N! / [(N – M)! * M!]

What I would like is a simple form solution for summing that equation with M = [1, N]. How many different sets can be drawn from the sack. We assume here that all sets of different sizes are totally different, ignoring the fact that the sets of size two are all made up of sets of size one.

I can readily write out or code up the computational solution. It starts off like this:

(N! / N-1!) + (N! / ((N-2)! * 2!) … (N! / N!)

Clearly there is a short form of this.

What is it?

–Update!–

By a variety of methods, we have our solutions:

  • technolope gets credit for being first with a workable answer.
  • robotify gets credit for stating his answer in such a way that it’s so pitifully obvious, I wonder how I didn’t see it right away.
  • _earthshine_ gets credit for explaining the answer in a way that most anyone will understand
  • And finally, jrtom gets 1/2 point, despite not providing a working answer. The reason for this is that I’m in awe of how his mind works: He seems to have assumed that we would never want to compute the answer for any pitiful, small numbers … so he jumped right to using a solution that involves an approximation for insanely huge ones that you can’t calculate in any reasonable time. Wow.

With friends like you guys, I’m never doing math again!

Linux Question

I’m benchmarking a monster machine with 12GB of RAM. I want to track, throughout my benchmarks, how much memory is in use as I run a variety of processes. I usually do this using ‘top’. If I’m feeling hardcore, I use “sysctl” or “free”. If I’m feeling truly badass, I read /proc/meminfo directly.

Problem: On Fedora Core 4, the “used” number seems to be a high-water mark, rather than a current usage mark. Even as I run “vmstat 5” and watch the lines scroll by, the memory never returns to the “free” column.

(a) is there a way to force the system to free this memory?
(b) is this a known failing of some kernel version or core? I’m running on ahem really sweet Xeons.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

This site uses Akismet to reduce spam. Learn how your comment data is processed.