You are viewing a single comment's thread. Return to all comments →
Simplest Solution Only few such numbers exist [:=)
pan8=[18,78,1728,1764,1782,1827,2178,2358,2718,2817,3564,3582,4176,4356] pan9=[9,192,219,273,327,6729,6792,6927,7269,7293,7329,7692,7923,7932,9267,9273,9327]
n, k = map(int, input().split(" ")) if k==8: for i in range(0,18): if pan8[i]<=n: print(pan8[i]) else: break
if k==9: for i in range(0,18): if pan9[i]<=n: print(pan9[i]) else: break
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #38: Pandigital multiples
You are viewing a single comment's thread. Return to all comments →
Simplest Solution Only few such numbers exist [:=)
pan8=[18,78,1728,1764,1782,1827,2178,2358,2718,2817,3564,3582,4176,4356] pan9=[9,192,219,273,327,6729,6792,6927,7269,7293,7329,7692,7923,7932,9267,9273,9327]
n, k = map(int, input().split(" ")) if k==8: for i in range(0,18): if pan8[i]<=n: print(pan8[i]) else: break
if k==9: for i in range(0,18): if pan9[i]<=n: print(pan9[i]) else: break