problem 16 in C & ruby