princeofsudan

ProjectEuler#52 Permuted multiples

Apr 5th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #It can be seen that the number, 125874, and its double, 251748, contain
  2. #exactly the same digits, but in a different order.
  3.  
  4. #Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x,
  5. #contain the same digits.
  6.  
  7. def isMultsPerms(n):
  8.     nStr = str(n)
  9.     if len(nStr) == len(str(n*2)) == len(str(n*3)) ==\
  10.        len(str(n*4)) == len(str(n*5)) == len(str(n*6)):
  11.         count = 0
  12.         for i in nStr:
  13.             if i in str(n*2) and i in str(n*3) and i in str(n*4)\
  14.                and i in str(n*5) and i in str(n*6):
  15.                 count += 1
  16.         if count == len(nStr):
  17.             return True
  18.         else:
  19.             return False
  20.  
  21. i = 1
  22. while True:
  23.     if isMultsPerms(i):
  24.         print i
  25.         break
  26.     i += 1
Advertisement
Add Comment
Please, Sign In to add comment