Java tutorial
//package com.java2s; public class Main { public static String getRepeat(int[] results) { String repeatstr = null; int repeat = 0; for (int i = 0; i < results.length; i++) { if (results[i] == 0) { repeat &= (~(1 << i)); } else { repeat |= (1 << i); } } repeatstr = String.valueOf(repeat); return repeatstr; } }