def apply_perm(omega,fbn):
    """
    
    omega contains a list which will be permuted (scrambled)
    based on fbm.
    
    fbm is a list which represents a factorial base number.
    
    This function just translates the pseudo code in the 
    Rosetta Code task.
    
    """
    for m in range(len(fbn)):
        g = fbn[m]
        if g > 0:
            # do rotation
            # save last number
            new_first = omega[m+g]
            # move numbers right
            omega[m+1:m+g+1] = omega[m:m+g]
            # put last number first
            omega[m] = new_first
            
    return omega