Skip to content

Instantly share code, notes, and snippets.

@tabvn
Created November 6, 2018 03:49
Show Gist options
  • Select an option

  • Save tabvn/ac439aecd6e2c634aa68d8faecce9bd8 to your computer and use it in GitHub Desktop.

Select an option

Save tabvn/ac439aecd6e2c634aa68d8faecce9bd8 to your computer and use it in GitHub Desktop.
void displayCoupleOfNumber(int n){
int b = 0;
int tmp = sqrt(n);
int a = tmp;
while(true){
if(a<=0 || b >= tmp){
break;
}
if(a*a + b*b < n){
cout << "(" << a << ", "<< b<< ")" << endl;
cout << "(" << b << ", "<< a<< ")" << endl;
b++;
}else{
a--;
b = 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment