Algorithm
1. Start
2. Input:
- Accept an integer as input and store it in a variable, let's call it 'num'.
3. Initialize an empty list to store factors, let's call it 'factors'.
4. Iterate from 1 to num:
a. Check if num is divisible by the current iteration variable:
- If yes, add the current iteration variable to the 'factors' list.
5. Output:
- Display the 'factors' list as the result.
6. End
Code Examples
#1 Code Example- Find the Factors of a Number
Code -
Python Programming
number = 69
print("The factors of {} are,".format(number))
for i in range(1,number+1):
if number % i == 0:
print(i)
Copy The Code &
Try With Live Editor
Output
#2 Code Example- Print factors of a user-provided number
Code -
Python Programming
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)
Copy The Code &
Try With Live Editor
Output
The factors of 469 are,1767469
Demonstration
Python Programing Example to Find the Factors of a Number-DevsEnv