Number of primes below 1000

Do not expect a SQL answer there. My daughter (9) came from school with this question, and I suspect the expected homework was to google for an answer. I am pretty schocked of such practice, teacher encouraging google to do your homework are clearly not from my generation…

Ok, back to the rules, pen and paper. We write down all numbers from 1 to 1000, we start graying out the 1, then the 4,6,8,10,12,… Then the 9 15 21 27 … Then the 25, 35, 55, … Then 7, 49, 77, … And so on.

After having grayed out 1 one, 499 twos, 166 threes, 66 fives, 37 sevens, 20 elevens, 16 thirteens, 10 seventeens, 8 nineteens, 6 twentythrees, 2 twentynines and 1 thirtyone, we counted the remaining numbers and got to the solution. We used the calculator, to gray out numbers like 23*43. But for sure no google there.

I had a similar feeling when my boy teacher ask my boy to look for a description of some exotic butterfly on wikipedia. Is this all what new generations kids can do? Search on google?

Back to google, I once asked in an interview to a young candidate : “How would you speed up a cursor for loop that increases the salary of the employees by 10% ?”. Answer : “I would search on google”.

Not worth mentioning all my traumatic experiences with IT specialists who advise to turn on some tuning magic they found on google to solve their own performance issue with poorly written code.

Using google is good. But do your homework kids :-)

6 thoughts on “Number of primes below 1000”

  1. select count(*) from (
    with
    n as (select level+1 n from dual connect by level+1 <= 1000),
    f as (select n from n where n <= sqrt(1000))
    select n from n
    minus
    select f1.n * f2.n from f f1, n f2
    )

  2. @jason Nice colors :-) actually I had to write down on paper the solutions using repeating pattern, like the number of two until 2 times 500 minus the two itself, the number of three not multiple of 2 until 2*3, the number of 5 until 2*3*5, the number of 7 until 2*3*5*7 and for the rest just write down 11*(11,13,17,19,23,29,31,37,39,41,43,47,53,59,61,67,71,73,79,83,89) etc

    @sokrates hmm, I wanted to have something my daughter could find amusing ;-)

  3. It’s said that one day a colleague of the famous scientist Dr. Albert Einstein asked him for his phone number. The colleague became perplexed when he watched Einstein grab a phone book to look it up. Baffled, the colleague asked, “You don’t know your own phone number?” Einstein replied, “Of course not! … Why would I remember anything I can look up?”

    Einstein made it a regular practice not to cloud his thinking with anything he could look up in under two minutes.

Leave a Reply

Your email address will not be published.


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>