Questions

How do you Find the Factors of a Number Program?

We used the for loop to find factors of a number program below. Read the steps given below for a more detailed explanation. 

Step 1: Choose any number

Step 2: Put every number ranging from 1 to that number in a loop

Step 3: If the number is divided evenly, without leaving any remainder behind then that is a factor. 

                    

Source Code:

numb=int(input("enter any number"))

facts=[]

for a in range(1,numb+1):

    if numb%a==0:

       facts.append(a)

print ("Factors of {} = {}".format(numb,facts))

Output

enter a number 6

Factors of 6 = [2, 3]

Related Questions

Related Topics

Share with friends

Customize your course in 30 seconds

Which class are you in?
5th
6th
7th
8th
9th
10th
11th
12th
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
tutor
tutor
Ashhar Firdausi
IIT Roorkee
Biology
tutor
tutor
Dr. Nazma Shaik
VTU
Chemistry
tutor
tutor
Gaurav Tiwari
APJAKTU
Physics
Get Started

Leave a Reply

Your email address will not be published. Required fields are marked *

Download the App

Watch lectures, practise questions and take tests on the go.

Customize your course in 30 seconds

No thanks.