Base-n-series generator for a given number in java,

I want to create a program to generate a series for a given base-n., For example, if my input is 2, then the series should be 00,01,10,11, etc., (binary) if my input is 10, then series should be, 1,2,3,4,5 etc., (decimal)

Is there any general mechanism for finding these numbers so that I can program for base-n.,

UPDATE: - After development, I run into a problem.

If I want to process this whole, how to do it? Some body commented on what BaseInteger class I should use. please specify

+3
source share
3 answers

To do this, you can use the Integer toString (int i, int radix) method .

:

Integer.toString(2, 2) // number 2, base 2

:

"10"

, 1 36.

+11

, , . , , , . , - (, int 10 2 2) . - , , , BaseNumber.

+1

Source: https://habr.com/ru/post/1745997/


All Articles