'I want to write a python programme that does repeated multiplication
A programme that asks the user to enter a number, multiply it by 2, and multiply the answer by 2, and so on, as many times as you want
Lets say the number is 100
Expected result
100×2= 200
200×2=400
400×2=800
800×2=1600,
and as many times i want
Solution 1:[1]
number = input("What number?")
iteration = input("How many times?")
for i in range(iteration):
new_number = number * 2
print(new_number)
number = new_number
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Damiaan |
