English

Write program to input any number and print all factors of that number.

Advertisements
Advertisements

Question

Write program to input any number and print all factors of that number.

Code Writing
Advertisements

Solution

Check every number from 1 to the given number; a factor leaves remainder 0.

n = int(input("Enter any number: "))

for i in range(1, n + 1):
    if n % i == 0:
        print(i)
shaalaa.com
  Is there an error in this question or solution?
Chapter 1: Review of Phython - EXERCISE [Page 26]

APPEARS IN

CBSE Computer Science with Python [English] Class 12
Chapter 1 Review of Phython
EXERCISE | Q 10. | Page 26
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×