Problem 3 in c

Doesn't run very fast.  Maybe there's a way to speed it up...