Slashdot Mirror


Fun with Prime Numbers

Steve Litt writes "Fun With Prime Numbers contains a series of prime number finding algorithms starting with the most brute force imaginable, and working up to a paged algorithm capable of finding the first 1,716,050,469 primes in an hour and a half on a commodity machine. There are faster algorithms on the net, but these algorithms are within the reach of mere mortals and are fully explained."

34 of 472 comments (clear)

  1. Obligatory by zedmelon · · Score: 5, Funny

    This article will be a prime target for bad jokes.

    --
    Mom says my .sig can beat up your .sig.
    1. Re:Obligatory by spellraiser · · Score: 2, Funny

      Don't worry ... I've got a grenade primed, ready to blow all the bad jokes to smithereens.

      --
      I hear there's rumors on the Slashdots
    2. Re:Obligatory by Anonymous Coward · · Score: 5, Funny

      We must not be divided on this issue.

    3. Re:Obligatory by dtfinch · · Score: 2, Funny

      7*191=1337

    4. Re:Obligatory by Trejkaz · · Score: 3, Funny

      Luckily when it comes to the quality of a Slashdot comment, bad jokes don't factor into it.

      --
      Karma: It's all a bunch of tree-huggin' hippy crap!
    5. Re:Obligatory by eclectro · · Score: 3, Funny

      This article will be a prime target for bad jokes

      It's true. Good jokes come alomg only so often, and we don't know when.

      --
      Take the cheese to sickbay, the doctor should see it as soon as possible - B'Elanna Torres, "Learning Curve"
    6. Re:Obligatory by conan776 · · Score: 3, Funny

      God sieve us from these bad puns....

      --
      "Reality is that which, when you stop believing in it, doesn't go away." -- Philip K. Dick
    7. Re:Obligatory by Surazal · · Score: 3, Funny

      Not only don't we know when, we don't remember the last time, either.

      --
      --- Journals are boring; Go to my web page instead
    8. Re:Obligatory by Hognoxious · · Score: 2, Funny

      Yes, they'll certainly be abundant, especially from the people who are deficient. Still, I shouldn't complain - nobody's perfect.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    9. Re:Obligatory by Infinityis · · Score: 1, Funny

      Or if we shall be divided, let it be by one among us, or by our very selves.

  2. Where is it? by TamMan2000 · · Score: 3, Funny

    I got a 404...

    --
    "I'll have a Guinness, no wait, make that a Coors Light" -Grad student I work with, who shall remain anonymous...
    1. Re:Where is it? by canwaf · · Score: 5, Funny

      Sorry, 404 isn't a prime number. Try again.

    2. Re:Where is it? by Baelrun · · Score: 3, Funny

      I got a 404.. That's not a prime number. No wonder the algorithm is so fast.

  3. "FUN with Prime Numbers" by noisymime · · Score: 2, Funny

    I find that title so hard to appreciate, maybe I'm just not as big a geek as i thought.

    1. Re:"FUN with Prime Numbers" by wwahammy · · Score: 2, Funny

      I've never found prime numbers to be fun at all. Derivatives on the other hand....

    2. Re:"FUN with Prime Numbers" by Anonymous Coward · · Score: 1, Funny

      You can find the gradient of my curve any day, if you know what I mean.

  4. This can't be good by Anonymous Coward · · Score: 2, Funny

    This sounds like one of those topics in high school where if you sounded interested you were written a raincheck for an after school beating by the rugby team.

  5. chosing typesafety over speed? by Anonymous Coward · · Score: 3, Funny

    So the macros knock the time down from 4.49 to 4.15 seconds -- less than a 10% reduction. In my opinion, that's not enough benefit to give up the robustness and typechecking of functions.

    I never thought that I'd see a C programmer type something like that.

  6. Re:This begs the question: by Anonymous Coward · · Score: 5, Funny

    Why waste disk space with primes instead of just recalculating them?

  7. Re:the factor command in Unix/Linux by 0racle · · Score: 5, Funny

    You don't really have friends do you.

    --
    "I use a Mac because I'm just better than you are."
  8. Re:the factor command in Unix/Linux by 3770 · · Score: 2, Funny


    Not among humans. And they are the only ones with phones.

    This is why I'm sharing this with the rest of you so that someone can use it.

    --
    The Internet is full. Go Away!!!
  9. Fun with primes? by The+Master+Control+P · · Score: 3, Funny

    How about when you're on the vintage mainframe level in Tron 2.0, ask some random program to calculate the seventh even prime number. When he segfaults, you get access to the directory containing Tron Legacy. Just don't ask yourself that question...

  10. Re:the factor command in Unix/Linux by bob+beta · · Score: 3, Funny

    If you want to be a true geek, you run factor against all the spare quartz crystals and oscillator blocks in your junkbox, to see which ones factor down to useful frequencies. 'A multiple of 9600 baud, hmmm....'

  11. Prime numbers in bad music... by Kenja · · Score: 2, Funny

    "One is the loneliest number that you'll ever do Two can be as bad as one, its the loneliest number since the number one"

    --

    "Have you ever thought about just turning off the TV, sitting down with your kids, and hitting them?"
  12. Reminds me of... by constandinos · · Score: 2, Funny

    My Holloween Costume!

    I marked up a sweatshirt with a bunch of random prime numbers and, dum roll please, I WAS the 'Indivisible Man'.

    Tada.
    ~tel0p

  13. Not as much fun as by Snoe · · Score: 5, Funny

    The Prime Number Shitting Bear. Watching a console window spit out prime numbers might do it for the geeks, but everyone can loves the prime number shitting bear.

  14. Re:A better use? by eclectro · · Score: 2, Funny

    Excuse my ignorance, but what are extremely large primes used for?

    Obviously to get a date with a hot chic so you can impress her with the math you know.

    --
    Take the cheese to sickbay, the doctor should see it as soon as possible - B'Elanna Torres, "Learning Curve"
  15. Re:What is special about prime numbers? by Anonymous Coward · · Score: 2, Funny

    Hand in your geek membership card. now.

  16. Re:This begs the question: by Goalie_Ca · · Score: 2, Funny

    Why waste time or space?

    --

    ----
    Go canucks, habs, and sens!
  17. How to prove that all odd numbers are prime by dargaud · · Score: 5, Funny

    "It was mentioned on CNN that the new prime number discovered recently is four times bigger than the previous record." --John Blasik

    "You know what seems odd to me? Numbers that aren't divisible by two." --Michael Wolf.

    "I don't get even, I get odder."

    How to prove that all odd numbers are prime? Well, this problem has different solutions whether you are a:

    • Mathematician: 1 is prime, 3 is prime, 5 is prime, 7 is prime, and by induction we have that all the odd integers are prime.
    • Physicist: 1 is prime, 3 is prime, 5 is prime, 7 is prime, 9 is an experimental error...
    • Engineer: 1 is prime, 3 is prime, 5 is prime, 7 is prime, 9 is prime...
    • Chemist: 1 prime, 3 prime, 5 prime... hey, let's publish!
    • Modern physicist using renormalization: 1 is prime, 3 is prime, 5 is prime, 7 is prime, 9 is ... 9/3 is prime, 11 is prime, 13 is prime, 15 is ... 15/3 is prime, 17 is prime, 19 is prime, 21 is ... 21/3 is prime...
    • Quantum Physicist: All numbers are equally prime and non-prime until observed.
    • Professor: 1 is prime, 3 is prime, 5 is prime, 7 is prime, and the rest are left as an exercise for the student.
    • Confused Undergraduate: Let p be any prime number larger than 2. Then p is not divisible by 2, so p is odd. QED
    • Measure nontheorist: There are exactly as many odd numbers as primes (Euclid, Cantor), and exactly one even prime (namely 2), so there must be exactly one odd nonprime (namely 1).
    • Cosmologist: 1 is prime, yes it is true....
    • Computer Scientist: 1 is prime, 10 is prime, 11 is prime, 101 is prime...
    • Programmer: 1 is prime, 3 is prime, 5 is prime, 7 is prime, 9 will be fixed in the next release, ...
    • C programmer: 01 is prime, 03 is prime, 05 is prime, 07 is prime, 09 is really 011 which everyone knows is prime, ...
    • BASIC programmer: What's a prime?
    • COBOL programmer: What's an odd number?
    • Windows programmer: 1 is prime. Wait...
    • Mac programmer: Now why would anyone want to know about that? That's not user friendly. You don't worry about it, we'll take care of it for you.
    • Bill Gates: 1. No one will ever need any more than 1.
    • ZX-81 Computer Programmer: 1 is prime, 3 is prime, Out of Memory.
    • Pentium owner: 1 is prime, 3 is prime, 5 is prime, 7 is prime, 8.9999978 is prime...
    • GNU programmer: % prime
      usage: prime [-nV] [--quiet] [--silent] [--version] [-e script] --catenate --concatenate | c --create | d --diff --compare | r --append | t --list | u --update | x -extract --get [ --atime-preserve ] [ -b, --block-size N ] [ -B, --read-full-blocks ] [ -C, --directory DIR ] [--checkpoint ] [ -f, --file [HOSTNAME:]F ] [ --force-local ] [ -F, --info-script F --new-volume-script F ] [-G, --incremental ] [ -g, --listed-incremental F ] [ -h, --dereference ] [ -i, --ignore-zeros ] [ --ignore-failed-read ] [ -k, --keep-old-files ] [ -K, --starting-file F ] [ -l, --one-file-system ] [ -L, --tape-length N ] [ -m, --modification-time ] [ -M, --multi-volume ] [ -N, --after-date DATE, --newer DATE ] [ -o, --old-archive, --portability ] [ -O, --to-stdout ] [ -p, --same-permissions, --preserve-permissions ] [ -P, --absolute-paths ] [ --preserve ] [ -R, --record-number ] [ [-f script-file] [--expression=script] [--file=script-file] [file...]
      prime: you must specify exactly one of the r, c, t, x, or d options
      For more information, type "prime --help''
    • Unix programmer: 1 is prime, 3 is prime, 5 is prime, 7 is prime, ...
      Segmentation fault, Core dumped.
    • Computer programmer: 1 is prime, 3 is prime, 5 is prime
    --
    Non-Linux Penguins ?
  18. Re:This begs the question by bertas28 · · Score: 3, Funny
    This somehow reminds me of a series of memorandum I came across in Paradox, a magazine published by the Melbourne Uni Math Society (MUMS).

    It consists of a bunch of proofs that there is no largest prime - the list of proofs is entitled "15 good reasons why Pure Mathematics is not taught to first year students." My favourites are:
    Proof by example:
    "Let x be the largest prime. Then x=91 but 91+6=97 which is prime. Therefore 91 cannot be the largest prime number. Therefore there is no largest prime."

    Proof by intuition:
    "Prime numbers are integers that can be divided by themselves only; prime numbers are odd with the exception of 2. By intuition as n->infinity, there will always be an odd number cannot be divided by another number besides itself."

    Proof by experimental data:
    "Suppose n is the highest prime. Then 2n-1 is also prime. But 2n-1>n so there is no highest prime. (Check: 2*2-1=3, 2*3-1=5, 2*5-1=11, 2*11-1=23, so true.)"

    But the greatest of them all:
    Proof by having no idea what a prime is:
    "Say the largest prime is x, then 2x is also a prime since the statement is true for all natural numbers."

    Go to http://www.ms.unimelb.edu.au/~paradox/archive/ for the magazine, these proofs appeared in issue 2 of 2002.

  19. Re:What is special about prime numbers? by Anonymous Coward · · Score: 2, Funny

    "very large primes that are difficult to factor."

    I can go even further and say that those large primes are IMPOSSIBLE to factor!

  20. You missed one by wowbagger · · Score: 2, Funny
    You missed one:
    Slashdot:
    • New prime number 11 found posted by Hemos
    • Conservatives hide evidence of new prime number to confound encryption posted by Michael
    • 9's primeness stolen by Republicans posted by Timothy
    • Primeness in a post-9 world posted by Jon Katz
    • New prime number 2 higher than 9 found posted by CmdrTaco
  21. Re:This begs the question: by StyroCupMan · · Score: 5, Funny
    If each number only has a 0.000703 chance of being prime, we can simplify this whole calculation with this function (pseudo-coded):

    boolean isPrime(int Number) {
    return false;
    }
    That function is 92.97% accurate. That's an A-. Good enough for me. :)
    --
    If I may say so, life is a game, and there's so much to do and so few turns.
    -Reiner Knizia