Thanks . Have some confusion here . If none of the condition in the Inner Loop satisfies , Does the loop continue to execute the next iteration of the Outer loop or Is in't supposed to repeatedly execute the inner loop for each of the value of Inner loop ($i here)

I have added a print debugger statement in the Inner for loop and here is what I get for the first few iterations

So 999 x 999 doesn't satisfy the conditions in the Inner Loop and I was then expecting i to be 999 and j to be 998 , But I see the print giving I as 998 and j as 999 .. Can you please help walkover this algorithm if possible ?

my $c = 0; I: for (my $i = $max; $i >= $min; $i--) { J: for (my $j = $max; $j >= $i; $j--) { my $prod = $i * $j; $c++; print "Iteration: $c, I: $i, J: $j Product: $prod\n"; .............. ............. Iteration: 1, I: 999, J: 999 Product: 998001 Iteration: 2, I: 998, J: 999 Product: 997002 Iteration: 3, I: 998, J: 998 Product: 996004 Iteration: 4, I: 997, J: 999 Product: 996003 Iteration: 5, I: 997, J: 998 Product: 995006 Iteration: 6, I: 997, J: 997 Product: 994009 Iteration: 7, I: 996, J: 999 Product: 995004 Iteration: 8, I: 996, J: 998 Product: 994008 Iteration: 9, I: 996, J: 997 Product: 993012

In reply to Re^2: Largest palindrome number for a 3 digit product of 2 numbers by pr33
in thread Largest palindrome number for a 3 digit product of 2 numbers by pr33

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.