Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # function to print originary solution to
- # X^2 + Y^2 + Z^2 = XYZ
- def printsol(x,y,z):
- X=3*x
- Y=3*y
- Z=3*z
- print(X,Y,Z)
- # function to calculate by recursion
- # the solution to Markov equation and
- # to print originary equation solution
- def markov(x,y,z,n):
- printsol(x,y,z)
- if(n > 0):
- if(z >= x):
- markov(x,z,3*x*z-y,n-1)
- if(z >= y):
- markov(y,z,3*y*z-x,n-1)
- return
- # executable code
- # depth level from input and
- # call to main function
- print("Insert depth level: ")
- n = int(input())
- print("X, Y, Z")
- markov(1,1,1,n)
Advertisement
Add Comment
Please, Sign In to add comment