title: Calculating square root for extremely large numbers in C
body: <p>I am solving some tasks from school olimpiads, and I got stuck on one question. I found the solution for the task, but my solution requires square rooting. My code works fine for first 12 inputs, but then it gives wrong answers. I guess that it is due to extremely large inputs, which can be as large as 10^400000. So I would like to know if there are ways to calculate whole number parts of square roots of these extremely large inputs in C. Here is the code:</p>
  
  <pre><code>#include &lt;math.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  int main(){
      long long n;
      scanf("%lld", &amp;n);
      long long ans;
      ans = sqrtl(n-1);
      long long result;
      result = ans+1-llabs(n-ans*ans-(ans+1));
      printf("%lld\n", result);
      return 0;
  }
  </code></pre>