(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-2960223314593660", enable_page_level_ads: true }); Program to print all factors of a given number. - TecGlance

Header Ads

Program to print all factors of a given number.

Algorithm:
Step 1: Start
Step 2: Read a number, num

Step 3: Repeat steps4,5&6  until i=num reach

Step 4: if num%i==0 then goto step 5
Step 5: Print i
 Step 6: Compute i=i+1
Step 7: Stop

Flowchart:

Program code: 
i=1
num=int(input('Enter a number '))
while i<=num:
    if num%i==0:
        print i
    i=i+1
 

No comments

Powered by Blogger.