Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Cube/digit script.

by Yzzyx (Beadle)
on Mar 10, 2006 at 09:28 UTC ( [id://535710]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Cube/digit script.

#!/usr/bin/perl use warnings; for my $a ( 1 .. 9 ) { for my $b ( 0 .. 9 ) { for my $c ( 0 .. 9 ) { my $num = $a.$b.$c; my $sum = ( $a ** 3 ) + ( $b ** 3 ) + ( $c ** 3 ); print "$num\n" if $num == $sum; } } }

Replies are listed 'Best First'.
Re^2: Cube/digit script.
by ptum (Priest) on Mar 10, 2006 at 09:36 UTC

    A minor quibble: I would avoid using $a and $b in this context, since they are global sort variables -- it has the potential to confuse a casual reader of your code. How 'bout $c, $d and $e instead? :)


    No good deed goes unpunished. -- (attributed to) Oscar Wilde

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://535710]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.