1 min read

The factor of any number is a whole number which exactly divides the number into a whole number without leaving any remainder.

For example, 3 is a factor of 9 because 3 divides 9 evenly leaving no remainder.

Create a Python program to find all the factors of a number.

Step 1: Take a number

Step 2: Loop over every number from 1 to the given number

Step 3: If the loop iterator evenly divides the provided number i.e. `number % i == 0`

print it.

```
number = 69
print("The factors of {} are,".format(number))
for i in range(1,number+1):
if number % i == 0:
print(i)
```

```
The factors of 69 are,
1
3
23
69
```

```
number = int(input("Enter a number "))
print("The factors of {} are,".format(number))
for i in range(1,number+1):
if number % i == 0:
print(i)
```

```
Enter a number 469
The factors of 469 are,
1
7
67
469
```

PROGRAMS

Latest from djangocentral

In Django, the request object contains a variety of information about the current HTTP request, including the query parameters. Query parameters are a way to pass additional information in the URL and are used to filter or sort data. The request object p…

Read more →

2 min read

In Django, related_name is an attribute that can be used to specify the name of the reverse relation from the related model back to the model that defines the relation. It is used to specify the name of the attribute that will be used to access the relat…

Read more →

2 min read