Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Calculate prime factors for a given numer in a perl one-liner

by andmott (Acolyte)
on Dec 15, 2010 at 17:11 UTC ( [id://877318]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    use strict;
    ...
        @p = ();
    }
    print $_, "\n" foreach @a;
    
  2. or download this
    $_ = 1 x shift;
    while( /^(11+?)\1+$/ ) {
    ...
        $_= 1 x ( length() / length $1 ) 
    }
    print length;
    
  3. or download this
    #!/usr/bin/perl
    use strict;
    ...
        print $y, "\n";
        redo;
    }
    
  4. or download this
    perl -le '$x=shift; for($y=2; $y<=$x; $y++) { next if $x%$y; $x/=$y; p
    +rint $y; redo }' 7
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://877318]
Approved by toolic
Front-paged by MidLifeXis
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-29 11:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found