Skip to content

Commit

Permalink
Root over n SQRT
Browse files Browse the repository at this point in the history
  • Loading branch information
imashiqe committed Jun 12, 2024
1 parent ae01446 commit 4129377
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions datastucture/module01/O_sqrtN.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include<bits/stdc++.h>

using namespace std;

int main()
{
// int n;
// cin>>n;
// for (int i = 1; i <=sqrt(n); i++)
// {
// if(n%i==0)
// {
// cout<<i<<" ";
// if(n/i !=i) cout<<n/i<<endl;
// }
// }

int n;
cin>>n;
for (int i = 1; i*i <=sqrt(n); i++)
{
if(n%i==0)
{
cout<<i<<" ";
if(n/i !=i) cout<<n/i<<endl;
}
}
return 0;
}

0 comments on commit 4129377

Please sign in to comment.