# Project Euler #38: Pandigital multiples

# Project Euler #38: Pandigital multiples

marcv81 + 0 comments The original Project Euler problem is very clear, however this problem statement makes no sense whatsoever. Something might have gotten lost in translation. Could a moderator please review?

SalvadorDali + 2 comments where is the number 1? 1 * 1 = 1, 1 * 2 = 2, ..., 1 * 8 = 8. So basically pandigital.

Dalimil + 0 comments Exactly ... The problem statement should specify that we're only looking for numbers > 1.

sidharth2606 + 0 comments Its written there 1 < M in the constraints part.

[deleted] + 0 comments My attempt at an alternate explanation to the problem statement:

Find all numbers between 2 and N whose concatenated product gives a pandigital.

A 1-K pandigital is defined in this problem as a K-digit number that only contains the numbers 1,2,3,...,K. So if K=4 then the number 1423 would be a pandigital since all the numbers from 1,2,3,4 is present and it's a 4-digit number. The number 12334 on the other hand isn't counted as a pandigital number since it's not a 4-digit number as required. Similarly, the number 1023 isn't 1-4 pandigital since all the numbers between 1,..,4 isn't included in the number (namely 4).

To find the concatenated product of the number, you need to multiply it with 1,2... until the length of the concatenated product is equal to or above K. I'll use K=8 as in the example. If we want to find the concatenated product of 2, then we'd first multiply it with 1 and then add it to our concatenated product (which I'll call p):

1*2 = 2

p <- 2

p = 2

Since p isn't a 8-digit number, we'll have to keep multiplying our number.

2*2 = 4

p <- 4

p = 24

We'll continue this procedure until p is an 8-digit number.

3*2 = 6

p <- 6

p = 246

4*2 = 8

p <- 8

p = 2468

5*2 = 10

p <- 10

p = 246810

6*2 = 12

p <- 12

p = 24681012

Now that p is a 8-digit number we can check if it's pandigital. Since all number from 1 to 8 doesn't appear in p, then we know that the number 2 doesn't meet the criteria and shouldn't be printed. Do this procedure from 2 to N as previously mentioned and print only those number whose concatenated product is pandigital.

I hope this helped. Good luck.

sjeuler + 0 comments The problem does not state that something like 9x9, 9x8, 9x7, 9x6 giving 81726354 would be illegal, but it can (only) be inferred from the sample output.:) :(

KalROFL + 0 comments At first, I was spending a lot of time thinking of what possible sets (1, 2, ..., n) would work in order to optimize. Then I discovered that trying all concatenated products N x (1, 2, ..., i) for 1 <= i <= 9, 1 <= N < 10,000 was still plenty fast.

anand_10 + 1 comment 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

akhzarfarhan + 0 comments Please try not to copy and paste the complete code here. If you find something interesting just hint here.

[deleted] + 3 comments i got test case 3 wrong..and remaning are passed. please help about test case 3...

ndsvw + 0 comments same problem. and I have no idea how to edit my code as it seems to be correct...

tomazurkiewicz + 2 comments Having K = 8: - for 1728 you get following digits: {'6', '1', '8', '7', '3', '2', '4', '5'} - for 1729 you get: {'9', '1', '8', '7', '3', '2', '4', '5'} While the first one is pandigital, the second one is not.

vika95vika + 0 comments I've had the same issue and as I've understood, some of the numbers I returned as pandigital had a zero itself. I'd checked for zero only multipliers of numbers, I mean if we check number 'a' than I'd checked only a*2, a*3 and so one if they contain zero, but I hadn't check 'a' itself. After adding zero check for 'a' I've got 3rd case right.

vectar31 + 1 comment Is 123456708 a 1-8 pandigital?

tyler_durden + 0 comments no.. 0 is not admissible

vijaydev2016 + 0 comments this problem lacks clarification that multiplier should be multiplied with consecutive natural numbers(1,2,3,4...) e.g. for 192 with (1,2,3) is correct but 78 with(1,4,7) is incorrect for k=8. but using recusion i have solved it.

Kuriocity + 0 comments Take the number 192 and multiply it by each of 1, 2, and 3: 192 Ã— 1 = 192 192 Ã— 2 = 384 192 Ã— 3 = 576 By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3) The same can be achieved by starting with 9 and multiplying by 1, 2, 3, 4, and 5, giving the pandigital, 918273645, which is the concatenated product of 9 and (1,2,3,4,5). What is the largest 1 to 9 pandigital 9-digit number that can be formed as the concatenated product of an integer with (1,2, ... , n) where n > 1?

Sort 23 Discussions, By:

Please Login in order to post a comment