Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: phi div by 0 error

by Athanasius (Abbot)
on Sep 01, 2013 at 14:27 UTC ( #1051805=note: print w/ replies, xml ) Need Help??


in reply to phi div by 0 error

Put this print statement in the second for loop:

print "Evens = $Evens, Odds = $Odds\n";

and you’ll see that on the sixth iteration, $Evens is 10 and $Odds is 11 — both referring to uninitialised elements of array @list. So the division becomes 0 / 0, which gives the error.

hdb has shown how to fix this.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


Comment on Re: phi div by 0 error
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1051805]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2015-07-02 05:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (27 votes), past polls