summaryrefslogtreecommitdiff
path: root/progs/a908.py
blob: 1e3125c7188051af1909837bd04df455bf974c2d (plain)
1
2
3
4
5
6
7
8
9
10
11
def take_L_and_F_set_bits(n) : 
    n = n | n >> 1
    n = n | n >> 2
    n = n | n >> 4
    n = n | n >> 8
    n = n | n >> 16 
    return ((n + 1) >> 1) + 1      
def toggle_F_and_L_bits(n) :  
    if (n == 1) : 
        return 0 
    return n ^ take_L_and_F_set_bits(n)