Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Perl vs. Python for prime numbers

by BrowserUk (Patriarch)
on Jun 13, 2013 at 22:24 UTC ( [id://1038849]=note: print w/replies, xml ) Need Help??


in reply to Perl vs. Python for prime numbers

Maybe not the point of your post, but that is one dumb algorithm for finding primes.

Why test even numbers greater than 2? Why test multiples of the primes already found? Why trial divide with Xs greater than sqrt(n)?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Perl vs. Python for prime numbers
by eyepopslikeamosquito (Archbishop) on Jun 14, 2013 at 10:09 UTC

    The algorithm is lifted straight from the standard Python documentation, presumably as a toy example to illustrate the quirky "else" clause of Python loop statements.

      Ug. Those docs sum up my feelings exactly:

      (Yes, this is the correct code. Look closely: the else clause belongs to the for loop, not the if statement.)

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-03-28 13:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found