Question: Write code that divides a positive number n in half until the resulting number is less than 1 . For this exercise, use a method

Write code that divides a positive number n in half until the resulting number is less than 1. For this exercise, use a method that doesn't require you to convert the integer n to a different data type. For example, if n =5, the first time through the loop should result in 2.5, the second time through should result in 1.25, and the third time through should result in 0.625. The loop should not be executed a forth time since 0.625<1.
(a) If n =50000, how many times through the loop will the code run?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!