def next_p2(n):
    """Returns the smallest integer, greater than n
    (n positive and >= 1) which can be obtained as power of 2.
    """
    if n < 1:
        raise ValueError('n must be >= 1')
    v = 2
    while v <= n:
        v = v * 2
    return v
