python solution so far (written C-esque to make it easier to translate to C++ later). A (much) more elegant solution could be written using functional features (w/ reduce(lambda x,y: x*y, ...))