 <p>Well this was an interesting problem and kept me guessing for a while... </p> <p>I wasn't able to derive the logic first but then I switched back to basics and derived the <code>boolean expression</code> for calculation the sum &amp; carry for a 3 bit operation and here is the solution:</p> <pre><code>public static BitSet addBitSet(int n, List&lt;BitSet&gt; bitSetList){ BitSet sumBitSet = new BitSet(n); for (BitSet firstBitSet : bitSetList) { BitSet secondBitSet = (BitSet) sumBitSet.clone(); System.out.println("A: " + printBitSet(firstBitSet, 6)); System.out.println("B: " + printBitSet(secondBitSet, 6)); boolean carryForNext = false, sum,a,b,c; for (int i = n - 1; i &gt;= 0; i--) { a=firstBitSet.get(i); b=secondBitSet.get(i); c=carryForNext; sum = a&amp;!b&amp;!c|!a&amp;!b&amp;c|!a&amp;b&amp;!c|a&amp;b&amp;c; carryForNext = a&amp;b&amp;!c|a&amp;!b&amp;c|!a&amp;b&amp;c|a&amp;b&amp;c; sumBitSet.set(i,sum); } System.out.println("SUM:" + printBitSet(sumBitSet, 6)); } System.out.println(printBitSet(sumBitSet, 6)); return sumBitSet; } </code></pre> <p>and here is the code for <code>printBitSet</code>:</p> <pre><code>public static String printBitSet(BitSet bitSet, int size) { StringBuilder builder = new StringBuilder(""); for (int i = 0; i &lt; size; i++) { if (bitSet.get(i)) builder.append("1"); else builder.append("0"); } return builder.toString(); } </code></pre>