Python program to find factors of a number
Find factors of a Number
In this Python Program we will calculate the factors of given number. The factors of a number can be calculated with the help of for loop starting from 1 to number itself in which range original number divided by 1 to number itself which number divides the original number completely. That number will be the factor of the original number.
Number : 16
Factors: 1, 2, 4, 8, 16
Step 1. Start
Step 2. Take a user input and store into int type number variable.
Step 3. Run a for loop starts from 0 to number + 1.
Step 4. Inside for loop, Check condition number % i == 0,
Step 5. After condition is true, then print the loop value.
Step 6. Stop
number = int(input("Enter the Number:")) for i in range(1, number+1): if number % i == 0: print(i, end=" ") # This code is contributed by Shubhanshu Arya (Prepinsta Placement Cell Student)
Enter the Number: 10
1 2 5 10