I am trying to generate n digit number with all ones using BigInteger.
for(int i=0;i<n;i++){
genL = genL.add(BigDecimal.valueOf(Math.pow(10,i)).toBigInteger());
System.out.println(i + " "+ genL);
}
I am expecting all ones in the output result sequence. But I am getting the below output. Zero is getting inserted for i = 23 and 24. Is there anything I am missing out?
0 1
1 11
2 111
3 1111
4 11111
5 111111
6 1111111
7 11111111
8 111111111
9 1111111111
10 11111111111
11 111111111111
12 1111111111111
13 11111111111111
14 111111111111111
15 1111111111111111
16 11111111111111111
17 111111111111111111
18 1111111111111111111
19 11111111111111111111
20 111111111111111111111
21 1111111111111111111111
22 11111111111111111111111
23 111111111111111101111111
24 1111111111111111101111111