From: "Aaron D. Gifford" Date: 2011-12-01T11:04:59+09:00 Subject: Re: Stupid question I Admin Tensor's solution modified to support digit strings up to 1149 characters long (which is the path my muddled brain was meandering down in my prior post): irb(main):001:0> s="2011";s.sum%(48*s.size) => 4 And to verify worst-case a string of 1149 nine digits: irb(main):002:0> s="9"*1149;s.sum%(48*s.size) => 10341 For longer strings, pass an argument to String#sum bigger than the default 16. Of course using non-arabic UTF-8 encoded digits makes things very intersting (a.k.a. fail), a la Devanagari digit six (the first non-arabic UTF code point for a digit my search turned up): 0x096c.chr(Encoding::UTF_8) a.k.a. "\u096C" Aaron out.