+ 2

How do I write a program in Python to display the following number series: 1 2 4 8 16 32 64 128 256 and so on.

how do I write a program in Python to take one as the first number and multiply the first number by 2 and multiply the result with two again and again?.

6th Jan 2018, 4:15 AM
Vishwatma Bhat
6 odpowiedzi
+ 2
You could write something like that : x = 1 while x<= 5000: print(x) x *= 2 And it will give you the numbers you want. I set it to 5000 but you can set it to a higher number if you want more numbers. Tell me if it works
6th Jan 2018, 4:32 AM
Hamsdino
Hamsdino - avatar
+ 2
a=int(input()) while a<=10000: print (a) a=a*2 # it satisfy your conditions till 10000
6th Jan 2018, 4:40 AM
‎ ‏‏‎Anonymous Guy
+ 2
it works. thanks mr hamsdino
6th Jan 2018, 4:40 AM
Vishwatma Bhat
+ 1
p=1; for i in range(10): print(p); p=p*2;
6th Jan 2018, 5:03 AM
Rashed Latif
Rashed Latif - avatar
19th Aug 2020, 4:47 PM
Galstyan
Galstyan - avatar
0
# Author: Huub Hoegen # Date: 22-02-2022 def main(number=2): Final = [0] for i in range(10): Final.append(number << i) print(Final) main()
22nd Feb 2022, 1:18 PM
Huub hoegen