Discover a wealth of information and get your questions answered on IDNLearn.com. Our platform offers reliable and detailed answers, ensuring you have the information you need.
Sagot :
Explanation:
I ran this on an online compiler with no issues, so I would try to use a different compiler if I were you. For example, sometimes the compiler can run a different program than the one you're currently on.
I would also recommend cleaning up the code. You don't need anything outside of the first part, as the latter 2 parts don't do anything because the number is already 0 by then.
Here's what I ended up with:
int userNum = 20;
while(userNum >= 1){
System.out.print(userNum + " ");
userNum = userNum/2;
}
return;
My output is:
20 10 5 2 1
Thank you for using this platform to share and learn. Don't hesitate to keep asking and answering. We value every contribution you make. Your questions deserve precise answers. Thank you for visiting IDNLearn.com, and see you again soon for more helpful information.