#!/usr/bin/python

# The one minute game challenge.  Make a game in 1 minute.

# (after) I didn't measure it, but this took about 2 minutes.  It's a game.
# Things that embarass me about it:
# - It requires a console to run.  It's not graphical.
# - It feels like edutainment.

import sys
import random
import math

def factors(n):
    ret = [i for i in range(2, n) if n % i == 0]
    return ret

def exit(n):
    f = factors(num)
    if len(f) >= 1:
        print str(num) + "'s factors were: " + " ".join(map(str, f))
    else:
        print str(num) + " was prime!"
    sys.exit(0)

num = 4
while(True):
    print num
    d = raw_input("divisor: ")
    d = int(d)
    if num % d != 0:
        print "Not divisible, game over."
        exit(num)
    if d <= 1:
        print "Too small, game over."
        exit(num)
    if d >= num:
        print "Too large, game over."
        exit(num)
    print "Adding {0} to {1}".format(d, num)
    num = num + d
    if bool(random.getrandbits(1)):
        num += 1
        print "The gremlin added one more!"
