------ art_298_27987425.1221956220267 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 2008/9/20 Holger Mack <hmack.gm / googlemail.com> > Periodicity of 1/n -> length of the recurring sequence of the decimal > fraction of 1/n > - 1/3 .3333333.... -> "3" -> 1 > - 1/7 .1428571428571.... -> "142957" -> 6 > - 1/11 .09090909.... -> "09" -> 2 > > a bonus point: other than decimal fraction def per(n, p 6) (1..(p/2)).detect { |x| ("%.#{p}f" % (1.0/n)).split(".").last.scan(%r{.{#{x}}}).uniq.size 1 } || 0 end This produces correct output for the numbers you specified. The optional 'p' param sets the precision level for converting the number to a string. ------ art_298_27987425.1221956220267--