Write a Java program that can take a positive integer greater than 2 as input and write out the numbers of times one must repeatedly divide this number by 2 before getting a value less than 2.

Recommended Answers

All 3 Replies

Sounds like home work. Try few lines and then ask for help. No body here is free to do your homework.

This shouldn't be too hard. Just use a loop that divides a number by 2 with the condition that the number divided must not be less than 2 and use a counter that increments for every loop, then when the loop finishes print out the counter

this is very easy, but then again: so far he has just copy pasted his school assignment. let's not jump to conclusions and wait until he actualy asks a question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.