Skip to content

Instantly share code, notes, and snippets.

@teepark
Created May 17, 2011 01:42
Show Gist options
  • Save teepark/975734 to your computer and use it in GitHub Desktop.
Save teepark/975734 to your computer and use it in GitHub Desktop.
import math
import sys
import traceback
def minus1(x):
return x - 1
def plus1(x):
return x + 1
def add_pos(x, y):
maxdepth = sys.getrecursionlimit() - len(traceback.format_stack())
chunksize = int(math.ceil(float(x) / maxdepth))
def recursion(x, y):
for i in xrange(chunksize):
if not y:
return x
x, y = plus1(x), minus1(y)
return recursion(x, y)
return recursion(x, y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment