Print all natural numbers in reverse (n to 1)

In this program, we will print all natural numbers in reverse (from n to 1) using a while loop

Steps to solve the program
  1. Take the last number from which you want to print the natural numbers as input through the user.
  2. Create a variable count and assign its value equal to the input number.
  3. Use a while loop to print the numbers in reverse order. 
  4. While the count variable is not equal to 0 print count and subtracts 1 from it each time.
  5. Print the output.
				
					n = int(input("Enter the last number: "))
count = n

while count != 0:
    print(count,end=" ")
    count -= 1
				
			

Output :

				
					Enter the last number: 10
10 9 8 7 6 5 4 3 2 1 
				
			

print all natural numbers from 1 to n

program to print all alphabets from a to z

Leave a Comment