in reply to Recurring Cycle of Fractions
Am I missing something, or is a simple regex all that is needed?
my @values = map { 1 / $_ } (2,3,6,7,9,11,13,14); for (@values) { /\.\d*?(\d+?)\1/; print "$_: $1\n" } __END__ 0.5: 0.333333333333333: 3 0.166666666666667: 6 0.142857142857143: 142857 0.111111111111111: 1 0.0909090909090909: 09 0.0769230769230769: 076923 0.0714285714285714: 714285
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Recurring Cycle of Fractions
by Skeeve (Parson) on Sep 09, 2007 at 17:45 UTC | |
by shmem (Chancellor) on Sep 09, 2007 at 19:15 UTC | |
by Sidhekin (Priest) on Sep 09, 2007 at 19:53 UTC | |
by Skeeve (Parson) on Sep 10, 2007 at 11:05 UTC |
In Section
Seekers of Perl Wisdom