三和数 ref: http://qiita.com/cielavenir/items/6022b3f4923ad4576d02