Advertisement
makispaiktis

Magic with 69

Mar 14th, 2021 (edited)
566
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. rightDigits = [str(i) for i in range(10)]
  2. for n in range(2, 101):
  3.     square = str(n**2)
  4.     cube = str(n**3)
  5.     digits = square + cube      # Data type of "digits" is string
  6.     digits = list(digits)
  7.     if len(digits) == 10:
  8.         # Now, my list "digits" contains all the digits from square and cube
  9.         if sorted(digits) == rightDigits:
  10.             print(n, n**2, n**3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement