def _autoFloat(f): from math import log10 as mloggg digits = (mloggg(f)) + 1 if (digits > 15): return mmmfloat(f) else: return mmmint(f)
def getSchroderTriangle(n=5, b=True): from sympy import Float as mmmfloat from math import log10 as mloggg colk = [k for k in range(n + 1)] a = [[1 if (j == 0) else 0 for j in colk] for i in colk] a[1][1] = 2 for i in range(1, n + 1): for j in range(1, i + 1): a[i][j] = a[i][j - 1] + a[i - 1][j - 1] + a[i - 1][j] if (b): if ((mloggg(a[i][j])) + 1 > 15): a[i][j] = mmmfloat(a[i][j]) return a
def DelannoySequence(n=5, returni=False, roundt=True): from sympy import Integer as mmmint from sympy import Float as mmmfloat a = [1, 3] for i in range(2, n + 2): b = (3 * (2 * i - 1) * a[i - 1] - (i - 1) * a[i - 2]) / i if (roundt == True): b = mmmint(b) else: b = mmmfloat(b) a.append(b) if (not returni): print(b, end=", ") if (returni): return a[:n]
def SchroderHipparchusSequence(n=5, returni=False, roundt=True): from sympy import Integer as mmmint from sympy import Float as mmmfloat a = [1, 1, 3] for i in range(3, n + 3): b = ((6 * (i + 1) - 9) * a[i - 1] - (i - 2) * a[i - 2]) / (i + 1) if (roundt == True): b = mmmint(b) else: b = mmmfloat(b) a.append(b) if (not returni): print(b, end=", ") if (returni): return a[:n] #SchroderHipparchusSequence(10,False,False) #SchroderHipparchusSequence(10,True)
def MotzkinSequence(n=5, returni=False, roundt=True): from sympy import Integer as mmmint from sympy import Float as mmmfloat a = [1, 1, 2] for i in range(3, n + 3): b = ((((2 * i + 1) / (i + 2)) * a[i - 1]) + (((3 * i - 3) / (i + 2)) * a[i - 2])) if (roundt == True): b = mmmint(b) else: b = mmmfloat(b) a.append(b) if (not returni): print(b, end=", ") if (returni): return a[:n] #MotzkinSequence(1000,False,False) #MotzkinSequence(1000,False)