Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
t = trailz(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.
t = bin(n)[::-1].find('1')
let t = n.trailing_zeros();
trailingZeros(Num) ->
trailingZeros(Num, 0).
trailingZeros(Num, Count) when Num band 1 == 0 ->
trailingZeros(Num div 2, Count + 1);
trailingZeros(_, Count) -> Count.
int t = 0;
if(n != 0)
{
while((n & 1) == 0)
{
t++;
n >>= 1;
}
}
else
{
t = 8 * sizeof(int);
}
var t = 0;
while (n.isEven && n != 0) {
t++;
n = n >> 1;
}
t = n.toRadixString(2)
.split('')
.reversed
.takeWhile((e) => e == '0')
.length;
t = n.bitLength - 1 - n.toRadixString(2).lastIndexOf('1');
$s = sprintf '%b', $n;
$n = length $s;
$t++ while !substr($s, --$n, 1) && $n >= 0;
$t = sprintf('%b', $n) =~ /(0+)$/ ? length($1) : 0;
Integer t = Integer.numberOfTrailingZeros(n);