Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose you have a number $n^m$. Is there a way to figure out how many 1s it contains "easily"? For large numbers, this probably means you do this without computing the value. What about 2s, or other digits?

Are there specific values of n, m for which you can (e.g. n is prime)?

This question arose when I was working on a recreational maths problem. At one point it was necessary to count how many 1s there are in a large prime power but I could not see how to do this without a calculator.

share|cite|improve this question
I'm pretty sure there isn't a way. at least not for all numbers. – Carry on Smiling Mar 17 '13 at 1:23
If your $n$ isn't divisible by $10$, I'd try using Euler's theorem for $10^k$ for each $k$th digit. – Alexander Gruber Mar 17 '13 at 4:55
If I were asked to do this, I'd give $\frac{m \times \log n}{10}$, as the answer, and hope that gods of probability are on my side :) – xylon97 Mar 17 '13 at 12:27
up vote 1 down vote accepted

To give you some idea of how hard this kind of problem is, $2^{86}=77371252455336267181195264$ is conjectured to be the greatest power of $2$ whose decimal representation has no zeros, but no one knows how to prove this. See this entry at the Online Encyclopedia of Integer Sequences.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.