""" It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits. """ from Helper import isPerm n = 1 while True: flag = True for i in range(2, 7): if not isPerm(n, i*n): flag = False break if flag == True: print n break n += 1
""" from Helper import isPerm import sys # Get all cube numbers with desired length def getCubesWith(length): start = int( (10 ** (length-1)) ** (1.0 / 3) ) end = int( (int(''.join(['9'] * length))) ** (1.0 / 3) ) return [i ** 3 for i in range(start, end + 1)] length = 8 print 'calculate numbers in length: ', while True: print length, cubes = getCubesWith(length) for i in cubes: perms = [i] for j in cubes[cubes.index(i)+1:]: if isPerm(i, j): perms.append(j) if len(perms) == 5: print perms sys.exit(0) # remove checked perm numbers for k in perms: cubes.remove(k) length += 1
""" The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbers are permutations of one another. There are no arithmetic sequences made up of three 1-, 2-, or 3-digit primes, exhibiting this property, but there is one other 4-digit increasing sequence. What 12-digit number do you form by concatenating the three terms in this sequence? """ from Helper import isPrime, isPerm n = 1489 # must be odd while True: b, c = n+3330, n+6660 if isPrime(n) and isPrime(b) and isPrime(c) \ and isPerm(n,b) and isPerm(b,c): break n += 2 print str(n)+str(b)+str(c)
import sys # Get all cube numbers with desired length def getCubesWith(length): start = int((10**(length - 1))**(1.0 / 3)) end = int((int(''.join(['9'] * length)))**(1.0 / 3)) return [i**3 for i in range(start, end + 1)] length = 8 print 'calculate numbers in length: ', while True: print length, cubes = getCubesWith(length) for i in cubes: perms = [i] for j in cubes[cubes.index(i) + 1:]: if isPerm(i, j): perms.append(j) if len(perms) == 5: print perms sys.exit(0) # remove checked perm numbers for k in perms: cubes.remove(k) length += 1