solution to #20

o Factored out sum_digits for problems that require digit summing
o solution to #20 looks correct but is maybe not working on some architectures because of a bug in bn_format
o wrote a test exposing the possible bug in bn_format