A Prime First Post

About a year and a half ago, I bought my domain name with plans to start a blog like the one you are now reading. Well, life happened, and my blog didn't. Until today. Today, I finally got around to shelling out the dough for cheap shared hosting (I choose DreamHost after reading through numerous reviews including Lifehacker's article here) and quickly set up a blog using WordPress. Eventually, I would like to build my own site from the ground up, but for now, I'm happy finally having my own web presence; 100% under my control! Woot!

This site is really more for myself than anyone else. It's a chance for me to record all the things which run through my mind all day (most of which relate to math, code, or mix of both (and sometimes physics (I mean, I'm a nerd. What do you expect? (I enjoy nesting parentheses several levels deep (no, really))))) and look back on them later. A sort of living journal of my technical thoughts, open to the world. That said, I'm fresh out of high school and I know I won't get everything right so if you notice any inaccuracies or would like to add to my ideas, feel free to comment!

To conclude, I would like to leave you with some Python code I wrote last summer. Because, I mean, why not? The code is just a single generator function (one of the many elegant features of the Python language which make it my first choice for quick programming tasks) that has the ability to sequentially find prime numbers. In fact, it will find every prime number, assuming you give it infinite computational resources. So, if you do have an infinity computer lying around in the backyard, feel free to use my algorithm to find the first prime number with 100 million digits and claim the $1,000,000 prize. I won't sue. I promise!

import math    

def prime_generator():
    """A generator functions which find prime numbers.
    >>> prime_gen = prime_generator()
    >>> next(prime_gen)
    2
    >>> next(prime_gen)
    3
    >>> next(prime_gen)
    5
    >>> next(prime_gen)
    7
    >>> next(prime_gen)
    11
    >>> next(prime_gen)
    13
    """
    yield 2
    yield 3
    n = 5
    sqrt_n = math.sqrt(n)
    divisor = 3
    while True:
        is_prime = divisor > sqrt_n
        is_not_prime = n % divisor == 0
        if is_prime or is_not_prime:
            if is_prime:
                yield n
            n += 2
            divisor = 3
            sqrt_n = math.sqrt(n)
        else:
            divisor += 2

P.S. As a UC Berkeley Electrical Engineering and Computer Sciences major who earned enough AP and Community College credit while in high school to only have 2 required humanities classes in college, writing like this is a good way for me to keep up my English ability. The best part: rather than exercising my penning abilities through literary research papers on the short lived nature of the many symbols in Ralph Ellison's Invisible Man, I can write about how Larry Ellison skipped his keynote speech at Oracle OpenWorld to watch Oracle Team USA progress toward victory in an epic America's Cup. Or, I can write about whatever else may float my boat (pun intended). Freedom, is great!