On Fri, 02 May 2008 10:28:00 -0500, Matthew Moss wrote: > Quiz #161 > Reverse Divisible Numbers > > This week's quiz is borrowed from Jon Galloway (http://tinyurl.com/ > 5jvf37). > Don't read the comments or solution there without trying this first! > > Your task is to write a bit of Ruby code that will find and report all > integers that are divisible by their reverse. For example, 9801 is > divisible by 1089. > > Your script should accept a single, optional argument to specify the > upper > limit of your search. If not provided, the default should be one > million. > > There are two extra rules for finding these "reverse divisible" numbers: > > 1. Don't count palindromes; they are obviously reverse-divisible. 2. > Don't count numbers ending with zero. Reversing such numbers forces you > to drop leading zeros on the divisor, and that's not as much fun. Here's what I've found: 1089 * 9 = 9801 2178 * 4 = 8712 10989 * 9 = 98901 21978 * 4 = 87912 109989 * 9 = 989901 219978 * 4 = 879912 real 0m55.234s user 0m53.995s sys 0m0.012s --Ken -- Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/