-1

Given a set of decimal digits. And given a set of primes $\mathbb{P}$, find some $p \in \mathbb{P}$ such that $p^n, n \in \mathbb{N} $ contained in itself all the digites from a given set, and it does not matter in what order.

  • You mean, you are given something like 0,1,4,5,6,7,8 and a possible answer the algotithm should find might be $7^8 = 5764801$? – Hagen von Eitzen May 25 '18 at 13:22
  • Yep.............. – Vladislav Kharlamov May 25 '18 at 13:23
  • Moreover, an algorithm is desirable that constructs at least a finite set of such examples, not the cardinality of the set 1 – Vladislav Kharlamov May 25 '18 at 13:24
  • Huh? To find examples, just pick a prime, raise it to a power, and collect the digits. Btw, would $8765401^1=8765401$ count as well? – Hagen von Eitzen May 25 '18 at 13:30
  • Then it remains to find an example for a given set of digits – Vladislav Kharlamov May 25 '18 at 13:35
  • E.g., for 0,1,4,5,6,7,8 as input we not only find $7^8$ and over 300(!) cases of primes "$p^1$", but also $2801^2=7845601$. I didn't look for cases of $p^3$ (one would just test $100<p<206$ to cover the numerical range); indeed, it seems to be a good idea to rather generate prime powers and check if they havethe right digots than vice versa – Hagen von Eitzen May 25 '18 at 13:37
  • If I understand correctly, you want to start with a (multi-)set of $n$ digits, and want an algorithm that will check whether any $n$-digit number using the given digits is a power of a prime, $p^m$ (including $m=1$). If so, the first thing I'd have the algorithm do is check whether the sum of the digits is a multiple of $3$, because if it is then you need only look for powers of $3$. – Barry Cipra May 25 '18 at 13:39
  • Not exactly, I'm looking for a given set of numbers just was. for $ {6,3}$ example: $2^{14} = 16384$ – Vladislav Kharlamov May 25 '18 at 13:44
  • @VladislavKharlamov I'm unclear what you're looking for - can the prime power contain other digits also? Can each digit from the target set be used only once? – B. Mehta May 25 '18 at 14:29
  • 1
    The longer you explain in reply to comments, the less clear the problem statement gets – Hagen von Eitzen May 25 '18 at 14:36
  • Please update your question to make clear what you are looking for. Make clear that digits can be added to the original set. Can the original digits come in any order? Can other digits come in between, so if we were give ${7,9}$ a good answer would be $729=3^6?$ Is it possible that there will be a repeat among the digits? – Ross Millikan May 25 '18 at 14:36
  • @VladislavKharlamov, it will help enormously if you edit your question to include your clarifications, rather than just responding in comments. It will also help enormously if you give some explicit simple examples of what you are looking for. – Barry Cipra May 25 '18 at 14:44
  • I tried to improve, I hope so much better ... Now I'll try to answer the questions if it's still not clear – Vladislav Kharlamov May 25 '18 at 14:46
  • Ah, I see you just edited the question. It will still help if you give an explicit example or two. E.g., is ${2,2,4}$ an example of a finite "set" of decimal digits, or is each digit allowed at most once? – Barry Cipra May 25 '18 at 14:47
  • $ {2,2,4} = {2,4} $ set, for $ {2,4}$ answer is: $2^{10} = 1024$ – Vladislav Kharlamov May 25 '18 at 14:52
  • Do you think it's probably better to delete the question? – Vladislav Kharlamov May 25 '18 at 14:55
  • @VladislavKharlamov, I don't think you can delete the question at this point, since it's received answers that have been upvoted. Ross Millikan's is particularly nice, at least if $2$ is in your set $\mathbb{P}$. – Barry Cipra May 25 '18 at 14:58
  • I regret that I left a negative impression about this task. Thanks to all for the answers, the answer with $2 ^ {100}$ is good. – Vladislav Kharlamov May 25 '18 at 15:00
  • 1
    The lesson is to think clearly about what you are asking. In the spirit of my answer, any large power of a prime will have lots of digits so will almost certainly include at least one of each (but $2^{99}$ is missing $9$). For any $p$ you have very good odds that $p^{10000}$ will satisfy your need. – Ross Millikan May 25 '18 at 15:04
  • Sounds related to this https://math.stackexchange.com/questions/2792978/exponentiating-the-natural-numbers/ – rtybase May 25 '18 at 22:22

3 Answers3

2

Remark: this answer pertains to the initial version of the question. The current edit restricts the search to powers within a given set of primes.

Another theoretically "cheap" way to look for prime powers that contain a given set of digits is to concatenate the $n$ digits, append a $1$ to get an $(n+1)$-digit number $d$ and then apply Dirichlet's theorem on primes in arithmetic progressions to the progression $10^{n+2}m+d$ for $m=1,2,3,\ldots$. (Appending the $1$ is necessary when, for example, the given digits are all even, in order to get a number $d$ that is relatively prime to $10$.) Dirichlet's theorem guarantees you'll find a prime, which can be checked for successive values of $m$ using, say, the AKS primality test if $n$ is large. If $n$ is small, say $n\approx10$, just about any primality test will do. Furthermore, the Prime Number Theorem (for primes in arithmetic progression) suggests you should find a prime relatively quickly.

Barry Cipra
  • 79,832
2

$2^{100}=1267650600228229401496703205376$ includes all the digits so it will answer your request for any set.

For any given prime it is believed that there is a highest power that does not contain all the digits, so if your list of primes doesn't include $2$ I would just raise one of them to the $1000$ power and expect it to be good. Proving that there is a highest power seems to be hard.

Ross Millikan
  • 374,822
  • Is this the first power of $2$ that has all ten digits? – Barry Cipra May 25 '18 at 14:59
  • @BarryCipra: I doubt it. I started with powers around $50$ and found at least one digit missing, then jumped to $2^{99}$ which is missing $9$. I was just computing in Alpha and looking. Next I tried $100$ and found them all. – Ross Millikan May 25 '18 at 15:01
  • I wonder if there is a largest power of $2$ that doesn't contain each digit at least once.... – Barry Cipra May 25 '18 at 15:11
  • 1
    @BarryCipra $2^{68}$ is the first power of $2$ that contains all digits, followed by $70,79,82,84,87,88,89,94$ – B. Mehta May 25 '18 at 15:31
  • @BarryCipra: I believe that has been asked here. I am sure there is-once you have enough digits you are almost sure to get them all, but I suspect it is very hard to prove. This and this ask it. No solutions are given. – Ross Millikan May 25 '18 at 15:35
  • @B.Mehta, nice to know! The extended list at http://oeis.org/A130694 indicates the last power of $2$ that doesn't include all ten digits may be $2^{168}$. – Barry Cipra May 25 '18 at 15:38
  • @BarryCipra: And oeis.org/A130696 is the list missing at least one digit. It says $168$ is believed to be the last. – Ross Millikan May 25 '18 at 15:40
1

More is true:

For any finite sequence of decimal digits, there is a power of $2$ whose decimal expansion begins with these sequence.

See here for a proof. For algorithms, see this question.

On the other hand, I've just run a computer search and every allowed subset of digits are the digits of a prime less than 304456880. Not all subsets of digits are allowed, of course: those whose sum is a multiple of $3$ are not. Nor are those solely composed of even digits. I've found $78$ forbidden subsets.

lhf
  • 216,483
  • I know, but here we need an algorithm – Vladislav Kharlamov May 25 '18 at 13:53
  • There's an obvious algorithm: start at $1$ and keep multiplying by $2$ until you get a number that contains the digits you're looking for. The theorem guarantees the process will produce an answer. (It doesn't say how quickly, but that's a different question.) – Barry Cipra May 25 '18 at 13:57
  • Well, it would be nice to somehow improve, but so well. – Vladislav Kharlamov May 25 '18 at 14:00
  • How have you concluded that multiples of $3$ and even digits are disallowed? Recall that OP asks for prime powers, not just primes. In addition, primes like $277$ give the set ${2,7}$, which has a sum a multiple of 3. – B. Mehta May 25 '18 at 14:23
  • Fair, but this still leaves numbers such as $243 = 3^5$ missing. – B. Mehta May 25 '18 at 14:31
  • @B.Mehta, indeed. My search finds $277$ for the set ${2,7}$. And $2243$ for ${2,3,4}$. – lhf May 25 '18 at 14:31