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

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

by jethro (Monsignor)
on Dec 15, 2010 at 17:55 UTC ( [id://877326]=note: print w/replies, xml ) Need Help??


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

That depends on a few other factors you don't mention: Is it a beginners course? What functions, operators or methods were teached directly before this homework? Would they be useful tools to solve the problem?

Generally the (mildly) difficult part seems to be to find a useful algorithm/mathematical formula to factor numbers, not the coding part as even your 16 line script will still fit into a single line if you just remove the newlines ;-)

PS: I just tried a very straightforward method and without trying to condense it used 91 characters with 8 statements, one of which was a while loop

  • Comment on Re: Calculate prime factors for a given numer in a perl one-liner

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-20 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found