diff options
Diffstat (limited to 'progs/a70.py')
-rw-r--r-- | progs/a70.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/progs/a70.py b/progs/a70.py new file mode 100644 index 0000000..6e61717 --- /dev/null +++ b/progs/a70.py @@ -0,0 +1,10 @@ +import math
+def get_Pos_Of_Right_most_Set_Bit(n):
+ return int(math.log2(n&-n)+1)
+def set_Right_most_Unset_Bit(n):
+ if (n == 0):
+ return 1
+ if ((n & (n + 1)) == 0):
+ return n
+ pos = get_Pos_Of_Right_most_Set_Bit(~n)
+ return ((1 << (pos - 1)) | n)
\ No newline at end of file |