Created
October 26, 2020 07:35
-
-
Save nagayev/b48d05b891750c8fa56b86365f258ff5 to your computer and use it in GitHub Desktop.
tribonacchi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def classic_round(x): | |
return int(x) if int(x)-x>=0.5 else int(x)+1 | |
def tribonacci(n): | |
sqrt33=33**0.5 | |
a1=(19+3*sqrt33)**(1/3) | |
a2=(19-3*sqrt33)**(1/3) | |
b=(586+102*sqrt33)**(1/3) | |
c=(1/3*(a1+a2+1))**n | |
d=b**2-2*b+4 | |
return classic_round(3*b*(c/d)) | |
print(tribonacci(5)) | |
print(ro(3.5)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment