{"id":22220,"date":"2021-09-23T19:08:56","date_gmt":"2021-09-23T13:38:56","guid":{"rendered":"https:\/\/python-programs.com\/?p=22220"},"modified":"2021-11-22T18:35:41","modified_gmt":"2021-11-22T13:05:41","slug":"python-program-to-print-series-1-2-4-8-16-32-n","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-print-series-1-2-4-8-16-32-n\/","title":{"rendered":"Python Program to Print Series 1, 2, 4, 8, 16, 32…n"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Swap Upper Diagonal Elements with Lower Diagonal Elements of Matrix.<\/a>
\nGiven a number N and the task is to print the series (1,2,4,8,16,32…N) <\/strong>till the given number N in Python.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 200<\/pre>\n

Output:<\/strong><\/p>\n

The above series till the given number{ 200 } is : \r\n1 2 4 8 16 32 64 128<\/pre>\n

Explanation:<\/strong><\/p>\n

1, 1*2, 2*2, 4*2, 8*2, 16*2, 32*2, 64*2\r\nwe cannot have 128*2=256 because it exceeds the given limit number 200.<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number = 50<\/pre>\n

Output:<\/strong><\/p>\n

The above series till the given number{ 50 } is :\r\n1 2 4 8 16 32<\/pre>\n

Explanation:<\/strong><\/p>\n

1, 1*2, 2*2, 4*2, 8*2, 16*2\r\nwe cannot have 32*2= 64 because it exceeds the given limit number 50.<\/pre>\n

Program to Print Series 1,2,8,16,32…n in Python<\/h2>\n

Below are the ways to print the series (1,2,8,16,32…N) <\/strong>till the given number N in Python:<\/p>\n