C# (.NET Core), (削除) 28+13=41 (削除ここまで) 35 bytes
n=>n-(1<<(int)System.Math.Log(n,2))
###Acknowledgements###
Acknowledgements
All credit for this answer goes to NieDzejkob; the mathematical approach is significantly better than binary string manipulation (below).
-6 bytes thanks @raznagul for seeing that System could just be included directly in the code, rather than as using System;.
C# (.NET Core), 86+13=99 bytes
n=>{var t=Convert.ToString(n,2).Remove(0,1);return t.Length<1?0:Convert.ToInt32(t,2);}
+13 bytes for using System;
###UnGolfed###
UnGolfed
n=>{
var t = Convert.ToString(n,2).Remove(0,1);
return t.Length < 1 ? 0
: Convert.ToInt32(t,2);
}
Unfortunately Convert.ToInt32 throws an exception on "", instead of returning 0.
C# (.NET Core), (削除) 28+13=41 (削除ここまで) 35 bytes
n=>n-(1<<(int)System.Math.Log(n,2))
###Acknowledgements###
All credit for this answer goes to NieDzejkob; the mathematical approach is significantly better than binary string manipulation (below).
-6 bytes thanks @raznagul for seeing that System could just be included directly in the code, rather than as using System;.
C# (.NET Core), 86+13=99 bytes
n=>{var t=Convert.ToString(n,2).Remove(0,1);return t.Length<1?0:Convert.ToInt32(t,2);}
+13 bytes for using System;
###UnGolfed###
n=>{
var t = Convert.ToString(n,2).Remove(0,1);
return t.Length < 1 ? 0
: Convert.ToInt32(t,2);
}
Unfortunately Convert.ToInt32 throws an exception on "", instead of returning 0.
C# (.NET Core), (削除) 28+13=41 (削除ここまで) 35 bytes
n=>n-(1<<(int)System.Math.Log(n,2))
Acknowledgements
All credit for this answer goes to NieDzejkob; the mathematical approach is significantly better than binary string manipulation (below).
-6 bytes thanks @raznagul for seeing that System could just be included directly in the code, rather than as using System;.
C# (.NET Core), 86+13=99 bytes
n=>{var t=Convert.ToString(n,2).Remove(0,1);return t.Length<1?0:Convert.ToInt32(t,2);}
+13 bytes for using System;
UnGolfed
n=>{
var t = Convert.ToString(n,2).Remove(0,1);
return t.Length < 1 ? 0
: Convert.ToInt32(t,2);
}
Unfortunately Convert.ToInt32 throws an exception on "", instead of returning 0.
C# (.NET Core), 28+13=41(削除) 28+13=41 (削除ここまで) 35 bytes
n=>n-(1<<(int)System.Math.Log(n,2))
###Acknowledgements###
All credit for this answer goes to NieDzejkob; the mathematical approach is significantly better than binary string manipulation (below).
-6 bytes thanks @raznagul for seeing that System could just be included directly in the code, rather than as using System;.
C# (.NET Core), 86+13=99 bytes
n=>{var t=Convert.ToString(n,2).Remove(0,1);return t.Length<1?0:Convert.ToInt32(t,2);}
+13 bytes for using System;
###UnGolfed###
n=>{
var t = Convert.ToString(n,2).Remove(0,1);
return t.Length < 1 ? 0
: Convert.ToInt32(t,2);
}
Unfortunately Convert.ToInt32 throws an exception on "", instead of returning 0.
C# (.NET Core), 28+13=41 bytes
n=>n-(1<<(int)Math.Log(n,2))
All credit for this answer goes to NieDzejkob; the mathematical approach is significantly better than binary string manipulation (below).
C# (.NET Core), 86+13=99 bytes
n=>{var t=Convert.ToString(n,2).Remove(0,1);return t.Length<1?0:Convert.ToInt32(t,2);}
+13 bytes for using System;
###UnGolfed###
n=>{
var t = Convert.ToString(n,2).Remove(0,1);
return t.Length < 1 ? 0
: Convert.ToInt32(t,2);
}
Unfortunately Convert.ToInt32 throws an exception on "", instead of returning 0.
C# (.NET Core), (削除) 28+13=41 (削除ここまで) 35 bytes
n=>n-(1<<(int)System.Math.Log(n,2))
###Acknowledgements###
All credit for this answer goes to NieDzejkob; the mathematical approach is significantly better than binary string manipulation (below).
-6 bytes thanks @raznagul for seeing that System could just be included directly in the code, rather than as using System;.
C# (.NET Core), 86+13=99 bytes
n=>{var t=Convert.ToString(n,2).Remove(0,1);return t.Length<1?0:Convert.ToInt32(t,2);}
+13 bytes for using System;
###UnGolfed###
n=>{
var t = Convert.ToString(n,2).Remove(0,1);
return t.Length < 1 ? 0
: Convert.ToInt32(t,2);
}
Unfortunately Convert.ToInt32 throws an exception on "", instead of returning 0.
C# (.NET Core), 28+13=41 bytes
n=>n-(1<<(int)Math.Log(n,2))
All credit for this answer goes to NieDzejkob; the mathematical approach is significantly better than binary string manipulation (below).
C# (.NET Core) , 86+13=99 bytes
n=>{var t=Convert.ToString(n,2).Remove(0,1);return t.Length<1?0:Convert.ToInt32(t,2);}
+13 bytes for using System;
###UnGolfed###
n=>{
var t = Convert.ToString(n,2).Remove(0,1);
return t.Length < 1 ? 0
: Convert.ToInt32(t,2);
}
Unfortunately Convert.ToInt32 throws an exception on "", instead of returning 0.
C# (.NET Core), 86+13=99 bytes
n=>{var t=Convert.ToString(n,2).Remove(0,1);return t.Length<1?0:Convert.ToInt32(t,2);}
+13 bytes for using System;
###UnGolfed###
n=>{
var t = Convert.ToString(n,2).Remove(0,1);
return t.Length < 1 ? 0
: Convert.ToInt32(t,2);
}
Unfortunately Convert.ToInt32 throws an exception on "", instead of returning 0.
C# (.NET Core), 28+13=41 bytes
n=>n-(1<<(int)Math.Log(n,2))
All credit for this answer goes to NieDzejkob; the mathematical approach is significantly better than binary string manipulation (below).
C# (.NET Core) , 86+13=99 bytes
n=>{var t=Convert.ToString(n,2).Remove(0,1);return t.Length<1?0:Convert.ToInt32(t,2);}
+13 bytes for using System;
###UnGolfed###
n=>{
var t = Convert.ToString(n,2).Remove(0,1);
return t.Length < 1 ? 0
: Convert.ToInt32(t,2);
}
Unfortunately Convert.ToInt32 throws an exception on "", instead of returning 0.