# How do I check if the base-$b$ representation of my number contains the same digits?

I came up with the following exercise with the intention of learning Mathematica but I am already stuck in the beginning. Let $$n,b$$ denote positive integers with $$n>0$$ and $$b\geq2$$. My aim is to check whether the base-$$b$$ representation of $$n$$ contains the same digits in base $$b$$.

For instance, $$n=63_{10}$$ has the representation $$n=111111_2$$ in base $$b=2$$ and $$n=124_{10}$$ is $$n=444_5$$ in base $$b=5$$.

I know that Mathematica can easily convert between two different bases using BaseForm[expr, base], but I have no idea how to efficiently verify whether the digits of the resulting number are all the same. I was looking for functions that work with repunits, but I found none. Any help is appreciated!

• Have a look at IntegerDigits (and, if you should ever need it, its inverse FromDigits). For example, IntegerDigits[63, 2] returns {1,1,1,1,1,1} and IntegerDigits[124, 5] returns {4,4,4}. Dec 17 '18 at 9:05

As @HenrikSchumacher mentioned, IntegerDigits works:
allSameQ[n_, b_] := Equal @@ IntegerDigits[n, b]

{True, True}