Skip to content

Instantly share code, notes, and snippets.

@iamandrewluca
Last active January 3, 2016 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamandrewluca/8422333 to your computer and use it in GitHub Desktop.
Save iamandrewluca/8422333 to your computer and use it in GitHub Desktop.
Extract number from a square root in 2 numbers
#include <stdio.h>
#include <math.h>
int main()
{
int x = 20;
int v1 = x, v2;
while ((v1 > 1) && ((x / (int)pow(v1,2)) != (x / pow(v1,2)))) v1--;
v2 = x / pow(v1,2);
printf("%d %d", v1, v2);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment