Program to print set of all divisors of a number.

Rajat Jadam
1 min readFeb 9, 2020

--

#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
int a;
cout<<”Enter the value of N:”;
cin>>a;
vector<int> d;
for(int i=1;i<(int)sqrt(a)+1;i++){
if(a%i==0){
d.push_back(i);
d.push_back(a/i);
}
}
cout<<”{ “;
for(int s:d){
cout<<s<<”,”;
}
cout<<”\b”;
cout<<” }\n”;
return 0;
}

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response