Divine Divisor Problem
Divine Divisors Problem
Divine Divisors Problem is one of the easy problems asked in TCS – Codevita. Here is the Python program to solve the Divine divisor problem where we need to find the divisors of a given number and print them in increasing order. To solve this problem we will use python programing language and search for all the divisors of the number and sort them to print them in increasing order. The difficulty level of this problem is low and can be solved easily here is the python solution for the problem.
Problem Description
Question -: Print a line containing all the divisors in increasing order separated by space.
Input Format: The first line of input contains an integer ‘N’ denoting the number.
Output Format: Print a line containing all the divisors in increasing order separated by space.
Constraints:
1 <= N <= 10^8
S.no | Input | Output | |
---|---|---|---|
1 | 10 | 1 2 5 10 | |
How do you find divisors?
If a number less then the given number divides the given number completely and leaves the remainder as 0[zero] then the number is considered as the divisor the number.
Python code to find the divisors of the given number is:
For i in range(1,number+1):
if number % i == 0:
print(i)
This code will print the divisors of the given number
Python Code to find all divisors of the given number
#take user input N = int(input('Enter the number :')) #initialize an empty list arr = [] #get the divisors of number for i in range(1,N+1): if N % i == 0: #append to list arr.append(i) #sort them in increasing order sorted(arr) #print the list print(arr)
Output 10 1, 2, 5, 10
Divine Divisors Problem in Other Coding Languages
C
To find the solution of Divine Divisors Problem in C Programming language click on the button below:
C++
To find the solution of Divine Divisors Problem in C++ Programming language click on the button below:
Java
To find the solution of Divine Divisors Problem in Java Programming language click on the button below: