Category Archives: by Aaron

Posts by Aaron

Programming Homework 3

Everything you need is in this secret zip file. (Download the file – right click on it and choose “save as”. If you just click on the link, it will try to open it as a pdf in your browser).

WordPress doesn’t let us host .zip files, so you’ll need to rename this “.pdf” file to .zip once you download it to use it.

By default, file extensions are not displayed for known file types on the computers in Weir.

First tell Windows not to treat you like a kid:

If you hit Start, then type “File extensions”, you should see an option called “Show or hide file extensions” in the start menu.

Without scrolling on the window that pops up, the second to last visible entry in that list of options is “Hide extensions for known file types”. Uncheck that box.

Apply, and you should be good to go to rename that “.pdf” file to a .zip.

Goldbach Conjecture functions

# returns True if num is prime, returns False otherwise
def isPrime(num):
    if num < 2:
        return False
    for n in range(2, int(num**0.5)):
        if num % n == 0:
            return False
    return True

# if num is even and greater than 2, returns the two primes that 
# sum to num (or -1 if Goldbach Conjecture is false)
# otherwise returns None
def checkGoldbach(num):
    if num % 2 == 0:
        for i in range(2, int(num/2) + 1):
            if isPrime(i) and isPrime(num - i):
                return i, num - i
        return -1