← back to unit
Medium
# loops
Grow the Magic Bean
A magic bean starts at size 1 and doubles in size every night. How many nights does it take until it's at least as big as the target size? 🌱
You're given a target size. Use a while loop: keep doubling size and counting nights until size is no longer smaller than the target. Print nights.
For example, target 10 → 1→2→4→8→16, which takes 4 nights.
💡 need a hint?
loop-double-until-big.py🔒 given lines are locked — write your code in between
loading...