in reply to Modulus zero error

Your looking at the wrong line (or being pointed at th wrong one?). The error is in this line:

while ($x % $p[$i] !=0) __________^

Examine what is said, not who speaks.        The end of an era!
"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
"Think for yourself!" - Abigail        "Time is a poor substitute for thought"--theorbtwo         "Efficiency is intelligent laziness." -David Dunham
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Replies are listed 'Best First'.
Re^2: Modulus zero error
by Anonymous Monk on Dec 24, 2004 at 05:19 UTC
    Yeah... I didn't really understand the line number - it said "line 25, <> line 3." (line 25 is the if statement) And when I truncate line 25, the error stops happening - i don't see how that line can affect the while part, since it's not changing anything..
      Cool

      The answer is perl has built a hash table in your while statement but when it comes to if it see's $p.. which is a new variable accordint to perl.. So there comes the problem. This is why it states the error in a wrong place


      Note:
      Use Strict and warnings

      Update:
      OOps sorry i mis understood the problem. Ok The problem lies in this line
      if (($n < $p[$i]) && ($x > $p[-1])) # error here

      just remove the previous code and use this u will not see the warning.
      if (($n < $p[$i]))

      This is becasue the lt operator should work by finding the modulus and then determine the solution.(I am not sure with that but for this error i hope this could be the reason. i will update on you again after 15 minutes

      Sorry i was not able to find it out....

      Thanks
      Sasi Kumar
        Eek... I don't understand, got lost at "built a hash table in your while statement" :( (I'm new to perl and programming in general, don't really know all that much about it yet...)

        I just want to know why
        if (($n < $p[$i]) & ($x > 2)) gives me errors and
        if (($n < $p[$i]) & ($x)) doesn't

        I tried use strict, warnings, didn't tell me anything different
        I didn't understand that at all; could you try to say it again?