File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ // time complexity of this algo is sqrt(n);
2+ /*
3+ written by pankaj kumar.
4+ */
5+ #include < algorithm>
6+ #include < string.h>
7+ #include < iostream>
8+ #include < vector>
9+ #include < cmath>
10+ #include < set>
11+ using namespace std ;
12+ typedef long long ll ;
13+ typedef vector<int > vi;
14+ typedef vector<pair<int ,int >> vpi;
15+ typedef vector<ll> vl;
16+ typedef vector<pair<ll,ll>> vpl;
17+ typedef vector<string> vs;
18+ typedef set<string> ss;
19+ typedef set<int > si;
20+ typedef set<ll> sl;
21+ typedef set<pair<int ,int >> spi;
22+ typedef set<pair<ll,ll>> spl;
23+ // macros
24+ #define pan cin.tie(0 );cout.tie(0 );ios_base::sync_with_stdio(0 );
25+ #define mod 1000000007 ;
26+ #define phi 1.618
27+ #define line cout<<endl;
28+ /* ascii value
29+ A=65,Z=90,a=97,z=122
30+ */
31+
32+ int main ()
33+ {
34+ int a,count=0 ;
35+ cout<<" Enter two number : " ;
36+ cin>>a;
37+ cout<<" List of all factor of " <<a<<" is : " ;
38+ for (int i=1 ;i<=sqrt (a);i++)
39+ {
40+ if (i%a==0 )
41+ {
42+ if (a/i==i)
43+ {
44+ count++;
45+ cout<<i<<" " ;
46+ }
47+ else
48+ {
49+ count+=2 ;
50+ cout<<a/i<<" " <<i;
51+ }
52+ }
53+ }
54+ line;
55+ cout<<" Hence total no of factor of " <<a<<" is " <<count<<endl;
56+ }
You can’t perform that action at this time.
0 commit comments