Exercise
Odd numbers descending
Objetive
Write a java program to display the odd numbers from 15 to 7 (downwards) on the screen using "while".
Example Code
public class Program {
// Main entry point of the program
public static void main(String[] args) {
// Initialize the starting number as 15
int number = 15;
// Start a while loop to display odd numbers from 15 to 7
while (number >= 7) {
// Display the current odd number
System.out.println(number);
// Decrease the number by 2 to get the next odd number in descending order
number -= 2;
}
}
}