Problem 063: (source):

```
object Euler063 extends EulerApp {
def pows (n :Int) = Stream.from(1) prefixLength(p => BigInt(n).pow(p).toString.length == p)
def answer = 1 to 9 map(pows) sum
}
```

The main observation here is that the number of digits of *a*^{x}, for *a* ≥ 10, is guaranteed to exceed *x*. So we can restrict ourselves to looking only at the numbers from 1 to 9. Furthermore, the number of digits of *a*^{x}, for 1 ≤ *a* ≤ 9, will equal *x* up to some maximum *x*, and then be less than *x* for all higher *x*. That enough *x*s for you?