below is my script. the incrementation loop works correctly until it hits 5.9 then it increments incorrectly just there. sample output follows the code.

#!/usr/bin/perl # zeta.pl c.2011 stan kulikowski ii, stankuli@etherways.com, pensacol +a, fl 32514 $SERIES_DEPTH = 1000000; &QUERY_DIRICHLET; sub QUERY_DIRICHLET { my $POWERS = 1; my $PRECISION = 0; print "\n Dirichlet's zeta function. \n"; my $OK = 0; until ($OK) { print " How many powers : "; chop($POWERS = <>); $POWERS = int $POWERS; ($POWERS > 1) ? $OK = 1 : print " value must be greater than 1 \n" +; } # until $OK # $OK = 0; until ($OK) { print " To what precision : "; chop($PRECISION = <>); ($PRECISION < 1 && $PRECISION > 0) ? $OK = 1 : print " value must +be between 1 and 0 \n"; } # until $OK # &DIRICHLET ($POWERS,$PRECISION); print "\n\n"; } # QUERY_DIRICHLET # sub HARMONIC_SERIES { my ($POWER) = @_; my $RESULT = 1; my $SERIES = $SERIES_DEPTH; while ($SERIES > 1) { $RESULT += 1/($SERIES-- **$POWER); } # while ($SERIES > 1) # return $RESULT; } # HARMONIC_SERIES # sub DIRICHLET { my ($POWERS,$PRECISION) = @_; my $POWER = 2; print "\n\n\t Power \t Dirichlet's zeta result (harmonic series dep +th = $SERIES_DEPTH)\n\n"; while ($POWER < $POWERS+1) { print "\t $POWER \t " . &HARMONIC_SERIES ($POWER) . " \n"; $POWER += $PRECISION; # problem here at 5.9? } # while ($POWER <= $POWERS) # } # DIRICHLET # # eof zeta.pl

here is what the output looks like:

Dirichlet's zeta function. How many powers : 6 To what precision : 0.1 Power Dirichlet's zeta result (harmonic series depth = 1000 +000) 2 1.64493306684877 2.1 1.56021630515022 2.2 1.49054320392715 2.3 1.43241778712389 2.4 1.38334285599691 2.5 1.34148725658587 2.6 1.30547780891302 2.7 1.27426464440048 2.8 1.24703142229228 2.9 1.22313389528938 3 1.20205690315031 3.1 1.18338365210598 3.2 1.16677337098058 3.3 1.15194479471816 3.4 1.13866377572624 3.5 1.12673386731579 3.6 1.11598907912243 3.7 1.10628824146401 3.8 1.09751057645852 3.9 1.08955218466995 4 1.08232323371086 4.1 1.07574569034329 4.2 1.06975147723364 4.3 1.0642809643257 4.4 1.05928172597973 4.5 1.05470751076137 4.6 1.0505173825665 4.7 1.04667500069907 4.8 1.04314801333513 4.9 1.03990754404931 5 1.03692775514334 5.1 1.03418547468746 5.2 1.03165987667789 5.3 1.0293322056832 5.4 1.02718553892034 5.5 1.02520457995467 5.6 1.02337547922702 5.7 1.02168567742621 5.8 1.02012376838834 5.9 1.01867937874473 5.99999999999999 1.01734306198444 6.09999999999999 1.0161062049622 6.19999999999999 1.01496094518522 6.29999999999999 1.0139000974628 6.39999999999999 1.01291708871218 6.49999999999999 1.01200589988852 6.59999999999999 1.01116101415427 6.69999999999999 1.01037737052638 6.79999999999999 1.00965032234471 6.89999999999999 1.00897559999333 6.99999999999999 1.00834927738192

In reply to incrementation loop fails? by stankuli

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.