A special site for solving fun programming problems and challenges, interested in computer science, programming, basics, data structure and algorithms

 K. Divisors

time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

--------------------------------------------------------------------------------------------------------------------------------


Given a number N. Print all the divisors of N in ascending order.

Input

Only one line containing a number N (1 ≤ N ≤ 104).

Output

Print all positive divisors of N, one number per line.

Examples

ExampleInputOutput
Ex(1)61
2
3
6
Ex(2)71
7
Ex(3)41
2
4


-----------------------------------------------------------------------------------------------------------------------------



program:
-----------------------------------------------------------------------------------


#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{

    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i;j++)
        {
            if(n%i==0)
            {
                cout<<i<<endl;
            }
            break;
        }
    }

    return 0;
}

*******************************************************



No comments:

Post a Comment