generate binary numbers from 1 to n in constant time O(1) for generating each number