Pattern pattern = Pattern.compile("(0+)$");
Matcher matcher = pattern.matcher(Integer.toBinaryString(n));
int t = 0;
if(matcher.find()) {
t = matcher.group(1).length();
}
Integer t = Integer.numberOfTrailingZeros(n);
function Trail(n: Integer): Integer;
var
Mask: Integer;
begin
T := 0;
while (T < SizeOf(Integer)*8) do
begin
Mask := 1 shl T;
if (n and Mask) <> 0 then Exit;
Inc(T);
end;
end;
begin
writeln(Trail(112),' (should be 4)');
end.
function Trail(n: Integer): Integer;
var
Mask: Integer;
begin
T := 0;
while (T < SizeOf(Integer)*8) do
begin
Mask := 1 shl T;
if (n and Mask) <> 0 then Exit;
Inc(T);
end;
end;
begin
writeln(Trail(112),' (should be 4)');
end.