What I have to do is get the user input and add consecutive numbers starting with one using a loop until the sum equals or exceeds the input. It's an exercise, so I'm trying to do this without using the condition True or importing any functions. Just a simple while loop.
This is what I've got.
num = int(input("Limit:"))
base = 0
while base < num:base += base + 1print(base)
When I input 21, the printout is 1 3 7 15 31
No idea how to fix. Any advice is greatly appreciated.
Edit: Sorry for not specifying, the expected output should only be the final number, that which exceeds or equals the input. So for instance, if input is 10, output should be 10. If input is 18, output should be 21.