def _autoFloat(f): from math import log10 as mloggg digits = (mloggg(f)) + 1 if (digits > 15): return mmmfloat(f) else: return mmmint(f)
def CompanionPellLucasNumber(Pell, roundi=True): from sympy import Integer as mmmint from sympy import N as mmmn r = Pell * (2**(1 / 2)) if (roundi): return mmmint(r) else: return mmmn(r)
def Binetformula(index, roundi=True): from sympy import Pow as mmmpow from sympy import Integer as mmmint from sympy import N as mmmn b = (mmmpow(1.6185, index) - mmmpow(-0.6185, index)) / 2.237 if (not roundi): return mmmint(b) else: return mmmn(b)
def LucasNumber(index, roundi=True): from sympy import Pow as mmmpow from sympy import Integer as mmmint from sympy import N as mmmrat b = (mmmpow(((1 + 5**(1 / 2)) / 2), index)) + (mmmpow( ((1 - 5**(1 / 2)) / 2), index)) if (not roundi): return mmmint(b) else: return mmmrat(b)
def CompanionPellNumber(index=1, roundi=True): from sympy import Pow as mmmpow from sympy import Integer as mmmint from sympy import N as mmmn q = 2**(1 / 2) r = (mmmpow(1 + q, index) - mmmpow(1 - q, index)) / (2) if (roundi): return mmmint(r) else: return mmmn(r)
def Binetformula(index=1, roundi=True): from sympy import Pow as mmmpow from sympy import Integer as mmmint from sympy import N as mmmn q = 2**(1 / 2) r = (mmmpow(1 + q, index) - mmmpow(1 - q, index)) / (2 * q) if (roundi): return mmmint(r) else: return mmmn(r)
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)