Write a snippet of code (not a full function) which prints o…
Write a snippet of code (not a full function) which prints out all of the powers of 2, from 1 to n. If n is not a power of two, stop after printing the power of 2 that follows it. (You may print the values out all on one line, or one per line.) Do not change n. Remember: The powers of two are 20 , 21 , 22 …. That is, they are 1, 2, 4, … As an example, if n==17, then print 1,2,4,8,16,32. But if n==4, print 1,2,4. You may assume that n is positive.