fantho69

x^2+y^2+z^2=xyz

Jan 22nd, 2026 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | Science | 0 0
  1. # function to print originary solution to
  2. # X^2 + Y^2 + Z^2 = XYZ
  3.  
  4. def printsol(x,y,z):
  5.     X=3*x
  6.     Y=3*y
  7.     Z=3*z
  8.     print(X,Y,Z)
  9.  
  10. # function to calculate by recursion
  11. # the solution to Markov equation and
  12. # to print originary equation solution
  13.  
  14. def markov(x,y,z,n):
  15.     printsol(x,y,z)
  16.     if(n > 0):
  17.         if(z >= x):
  18.             markov(x,z,3*x*z-y,n-1)
  19.         if(z >= y):
  20.             markov(y,z,3*y*z-x,n-1)
  21.     return
  22.  
  23. # executable code
  24. # depth level from input and
  25. # call to main function
  26.  
  27. print("Insert depth level: ")
  28. n = int(input())
  29. print("X, Y, Z")
  30. markov(1,1,1,n)
Advertisement
Add Comment
Please, Sign In to add comment