Yet another "round to arbitrary sequence" question -- powers of 2. Given a non-negative integer, what is the closest integer that is also an integer power of 2? This one actually might have some potential application, as integer powers of 2 are represented by a single bit in a digital sequence -- numbers that are the easiest to work with in digital circuits, so we might want to approximate some numbers to work with "easier" numbers instead.
The input file DATA2.txt will contain 5 lines, integers 0 <= N <= 65536
The output file OUT2.txt will contain 5 lines, corresponding integers rounded to the closest integer power of 2. If there are two integers equally far away, then use the higher value for the answer.
The sequence starts as: 1, 2, 4, 8, 16, 32, ..., 2n
0 1 2 3 5
1 1 2 4 4