You are viewing a single comment's thread. Return to all comments →
For this and also problem 33 I found it very useful to implement a function which returns an integer that is invariant to permuting the digits in .
This can be done by returning a product of prime factors where the exponents are the number of times each digit occur in n.
In python this can be implemented as follows:
pfs = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) def p(n, ten_pfs=pfs): result = 1 while n: n, d = divmod(n, 10) result *= pfs[d] return result
So for the example given . Then it is just a matter of finding those where by iterating over the possible values of .
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #52: Permuted multiples
You are viewing a single comment's thread. Return to all comments →
For this and also problem 33 I found it very useful to implement a function which returns an integer that is invariant to permuting the digits in .
This can be done by returning a product of prime factors where the exponents are the number of times each digit occur in n.
In python this can be implemented as follows:
So for the example given . Then it is just a matter of finding those where by iterating over the possible values of .