small factorial spoj solution in c++