You are viewing a single comment's thread. Return to all comments →
Java
public static long strangeCounter(long t) { // Write your code here //3*2^0 + 3 * 2^1 + 3*2^n long x = 0L; long i = 0L; long s = 0L; long k = 1L; while(x < t){ x = (long)(3 * Math.pow(2,i)); k += x; if(k > t) { s = k - t; break; } i++; } return s; }
Seems like cookies are disabled on this browser, please enable them to open this website
Strange Counter
You are viewing a single comment's thread. Return to all comments →
Java