C++ Program to find all the divisor of a given number
Description :
Given a natural number n, print all distinct divisors of it.
C++ Program to find all the divisor of a given number
#include<bits/stdc++.h>usingnamespacestd ;
intmain(){
int n , i;
cout<<" Enter the number to find its divisor \n";
cin>>n;
cout<<" All the divisors of "<< n <<" are "<< endl;
for( i=1 ; i <= n ; i++)
{
if( n % i == 0)
{
cout<< i <<" ";
}
}
return0;
}
Comments