in reply to Question on Recursion

Now that you have found the recursion problem, I'd write it without recursion. Or looping.
print "$num == 9\n" unless $num % 9;
will do as well.

Replies are listed 'Best First'.
Re^2: Question on Recursion
by roboticus (Chancellor) on Jan 09, 2009 at 13:23 UTC
    JavaFan:

    Not quite ... it'll only print the 9s! I'd suggest:

    print "num=$num, result=", ($num ? substr("912345678", $num%9, 1) : 0) +, "\n";
    ...roboticus
      Well, considering the OP has:
      print "$num == 9\n" if ($total1 == 9);
      only printing the 9s was done on purpose, as that's what the OP is doing.