Problems? Is your data what you think it is? PerlMonks

### Re: Perl vs. Python for prime numbers

by BrowserUk (Pope)
 on Jun 13, 2013 at 22:24 UTC ( #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 (Chancellor) 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.

Create A New User
Node Status?
node history
Node Type: note [id://1038849]
help
Chatterbox?
 [Lady_Aleena]: It could have meant a "Miserably Cute Event" or "Man Crush Everyday". 8) [Corion]: choroba: Re the one-shot thing, I also thought of bit vectors and/or indexes into one common array from the hashes, but that makes maintenance of all these indices a chorse [Corion]: *core [Corion]: ** chore [Corion]: So I guess I will simply implement the linear scan first and wait with more fancy stuff until it becomes a problem [karlgoethebier]: Lady_Aleena: ++ for "The Man Crusher Everyday" [karlgoethebier]: this mad my day [karlgoethebier]: no typo [marioroy]: At the Fransiscan monastery, got stuck up high in a tree from pruning and the chainsaw with large branch fell and broke the latter, but not me fortunately. Was stuck there for a while until a firetruck came by. [Corion]: marioroy: So you live dangerously ...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (13)
As of 2017-05-29 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My favorite model of computation is ...

Results (192 votes). Check out past polls.