#include<bits/stdc++.h>
using namespace std;
vector<int>divi[1000000];
void divisors(int n)
{
int i, j;
for(i=1;i<=n;i++)
{
for(j=i;j<=n;j+=i)
{
divi[j].push_back(i);
}
}
}
int main()
{
int n, i, j;
cout << "Enter Number :: ";
cin >> n;
divisors(n);
cout << "Each Number Divisors :: " << endl;
for(i=1;i<=n;i++)
{
cout << i << ": ";
for(j=0;j<divi[i].size();j++)
cout << divi[i][j] << " ";
cout << endl;
}
return 0;
}
using namespace std;
vector<int>divi[1000000];
void divisors(int n)
{
int i, j;
for(i=1;i<=n;i++)
{
for(j=i;j<=n;j+=i)
{
divi[j].push_back(i);
}
}
}
int main()
{
int n, i, j;
cout << "Enter Number :: ";
cin >> n;
divisors(n);
cout << "Each Number Divisors :: " << endl;
for(i=1;i<=n;i++)
{
cout << i << ": ";
for(j=0;j<divi[i].size();j++)
cout << divi[i][j] << " ";
cout << endl;
}
return 0;
}
Comments
Post a Comment