(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-2960223314593660", enable_page_level_ads: true }); Program to print natural numbers from n to 1. - TecGlance

Header Ads

Program to print natural numbers from n to 1.


Algorithm:
Step 1: Start
Step 2: Read a number, num
Step 3: Repeat step  4&5 until num=0 reaches

Step 4: Print num

Step 5: Compute num=num-1

Step 6: Stop

Flowchart:



Program code:
num=int(input('Enter a number '))
while num>0:
    print num
    num=num-1

No comments

Powered by Blogger.