Welcome to Westonci.ca, where you can find answers to all your questions from a community of experienced professionals. Our Q&A platform offers a seamless experience for finding reliable answers from experts in various disciplines. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.
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
Thanks for using our service. We aim to provide the most accurate answers for all your queries. Visit us again for more insights. Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. Thank you for trusting Westonci.ca. Don't forget to revisit us for more accurate and insightful answers.