in reply to finding perfect numbers
use strict; use 5.012; use Math::Factor::XS qw/factors/; use List::Util qw/sum/; for (2 ... 10000) { say "$_ is perfect" if sum(factors($_)) == $_ - 1; }
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: finding perfect numbers
by hexcoder (Curate) on Aug 05, 2010 at 21:44 UTC | |
by CountZero (Bishop) on Aug 06, 2010 at 10:56 UTC |