Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Finding all divisors of an integer

by Sidhekin (Priest)
on Jul 03, 2004 at 14:01 UTC ( [id://371578]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    @divisors = grep { $number % $_ == 0 } 1 .. $number;
    
  2. or download this
    # First, the lower half of the divisors:
    @divisors = grep { $number % $_ == 0 } 1 .. sqrt($number);
    # Then, the upper half:
    push @divisors, map {$number == $_*$_ ? () : $number/$_} reverse @divi
    +sors;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-18 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found