All pastes #536711 Raw Edit

python program to solve the prob

public python v1 · immutable
#536711 ·published 2007-06-04 14:22 UTC
rendered paste body
# Solve original equation for y# x + y - x*y = 79#     y - x*y = 79 - x#   y * (1-x) = 79 - x#           y = (79-x) / (1-x)# Find the value for y using integer math# then check whether this gives the exact valuedef candidate(x):    y = (79-x) / (1-x)    z = x + y - (x*y)    if y != 0 and z == 79: print x, y# Starting at x=2, try x and -x as candidates# Zero is ruled out by the problem statement, and# 1 causes division by zero so it can't be a valid 'x' either# just keep going until interrupted, though there don't seem to be any# integer solutions for |x| > 77def main():    from itertools import count    try:        for x in count(2):            candidate(x)            candidate(-x)    except KeyboardInterrupt:        print "last number considered:", xmain()