Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Unable to Understand grep and hash use for prime no.

by danaj (Friar)
on Aug 05, 2015 at 08:02 UTC ( #1137474=note: print w/replies, xml ) Need Help??


in reply to Re^2: Unable to Understand grep and hash use for prime no.
in thread Unable to Understand grep and hash use for prime no.

It looks like it is from "Beginning Perl" by Curtis Poe. Page 300 has the whole program, page 301 discusses is_prime() which is non-optimized trial division (checks divisibility by all integers up to sqrt(n)). Page 302 discusses the code in question which is introducing using a hash to cache the result.

In particular, the test suite includes duplicates in its list. That's why the hash is used.

  • Comment on Re^3: Unable to Understand grep and hash use for prime no.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2022-01-28 20:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (73 votes). Check out past polls.

    Notices?