Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Try your attempt with 17 and 19...

I do. Since there aren't enough digits, Math::BigFloat to the rescue:

#!/usr/bin/perl use Math::BigFloat; Math::BigFloat->div_scale(50); my @values = map { my $i = Math::BigFloat->new( 1 ); scalar $i->bdiv( $_ ); } (2,3,6,7,9,11,13,14,17,19,23); for (@values) { /\.\d*?(\d+?)\1/; print "$_: $1\n" } __END__ 0.5: 0.33333333333333333333333333333333333333333333333333: 3 0.16666666666666666666666666666666666666666666666667: 6 0.14285714285714285714285714285714285714285714285714: 142857 0.11111111111111111111111111111111111111111111111111: 1 0.090909090909090909090909090909090909090909090909091: 09 0.076923076923076923076923076923076923076923076923077: 076923 0.071428571428571428571428571428571428571428571428571: 714285 0.058823529411764705882352941176470588235294117647059: 058823529411764 +7 0.052631578947368421052631578947368421052631578947368: 052631578947368 +421 0.043478260869565217391304347826086956521739130434783: 043478260869565 +2173913

The regex is the same, though. Still missing something?

update: Oh, I see. "try with 170..." :-)

--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}

In reply to Re^3: Recurring Cycle of Fractions by shmem
in thread Recurring Cycle of Fractions by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-18 23:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found