Hello,
I am writing a C++ program to find the largest such number such that the square root of that number is less than or equal to a fixed number, set by me, like this:
#include <stdio.h>
#include <math.h>
int main (void)
{
long fixed, param, result;
result = 0;
param = 1;
fixed = 20;
while (result < fixed) {
result = sqrt(param);
param++;
}
param -= 1;
printf ("%d\n", param);
return 0;
}
This works fine as is, but the trouble is that my fixed is a number between 10^6 and 3 * 10^15, so this code is not optimal for computing values on such large scale. What can be done to increase efficiency?
Thank you.