using System;
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine(hitungNomorBit(13, 0));
Console.WriteLine(hitungNomorBit(13, 1));
Console.WriteLine(hitungNomorBit(13, 2));
}
public static int? hitungNomorBit(int angka, int nomorBit)
{
List<int> binerList = new List<int>();
while (angka > 0)
{
binerList.Add(angka % 2);
angka = angka / 2;
}
binerList.Reverse();
if (nomorBit >= binerList.Count)
{
return null;
}
return binerList[nomorBit];
}
}
dXNpbmcgU3lzdGVtOwoKcHVibGljIGNsYXNzIFByb2dyYW0KewogICAgcHVibGljIHN0YXRpYyB2b2lkIE1haW4oc3RyaW5nW10gYXJncykKICAgIHsKICAgICAgICBDb25zb2xlLldyaXRlTGluZShoaXR1bmdOb21vckJpdCgxMywgMCkpOwogICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKGhpdHVuZ05vbW9yQml0KDEzLCAxKSk7CiAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoaGl0dW5nTm9tb3JCaXQoMTMsIDIpKTsKICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIGludD8gaGl0dW5nTm9tb3JCaXQoaW50IGFuZ2thLCBpbnQgbm9tb3JCaXQpCiAgICB7CiAgICAgICAgTGlzdDxpbnQ+IGJpbmVyTGlzdCA9IG5ldyBMaXN0PGludD4oKTsKCiAgICAgICAgd2hpbGUgKGFuZ2thID4gMCkKICAgICAgICB7CiAgICAgICAgICAgIGJpbmVyTGlzdC5BZGQoYW5na2EgJSAyKTsKICAgICAgICAgICAgYW5na2EgPSBhbmdrYSAvIDI7CiAgICAgICAgfQoKCiAgICAgICAgYmluZXJMaXN0LlJldmVyc2UoKTsKCiAgICAgICAgaWYgKG5vbW9yQml0ID49IGJpbmVyTGlzdC5Db3VudCkKICAgICAgICB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0KCgogICAgICAgIHJldHVybiBiaW5lckxpc3Rbbm9tb3JCaXRdOwogICAgfQp9