Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Cube/digit script.

by Andrew_Levenson (Hermit)
on Mar 10, 2006 at 14:21 UTC ( [id://535705]=note: print w/replies, xml ) Need Help??


in reply to Re: Cube/digit script.
in thread Cube/digit script.

Here, I figured out what was wrong.
The $added variable was unnecessary:
use strict; use warnings; my $i; my $j; my $cubed; my @num; my @numbers; for $i(100..999){ undef($cubed); undef(@num); @num=split(//, $i); for $j(@num){ $cubed+=$j**3; } if($cubed==$i){ push @numbers, $i; } } print "$_\n" for @numbers;
Thanks for the help!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-25 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found