Back to General discussions forum
expexted ans- 314159265358979323843151646426332908840484683897389983893201554568642560 my ans- 314159265358979478289801511118377822379483923662804815679777338910834688 can anyone help me with sol as I am losing precision after 20 digits
Are you getting all the right numbers for the first few steps of the example on the page?
I had an issue with my sqrt function so without seeing your code, that might be somewhere to start.
can you check mycode?tell me where to send?
I think its OK to just post it here. If you indent the code with four spaces, the forum will turn it into a code block and make it easier to read.
I have already solved.thank you for your concern.
and what was the issue? how you solved it? I have exactly the same mistake.
Hint: if you are using Python, you don't need sqrt. There's math.isqrt that's perfect for this purpose.
Hi, im using vala (that is very similar to C#). and following the info in the problem's explanation I code the loop for calculating the sqrt using newton's method, but I still having the same answer. Also I use floor in all divisions by 2, as the problem suggest. :(
but I still having the same answer
the what answer?
sorry, Friend, your code is bit too excessive to understand it easily... either try describing your problem more clearly, or perhaps switch temporarily to other problems and return to this one later
Also, I'm not sure, but if you use finite-precision numbers, probably you won't go far with them
Here's the crucial line in the problem:
we should use as a result the greatest integer M such that when squared it does not exceed Z (i.e. M*M <= Z).
However you implement that (say, as a standalone function), the rest of your code shouldn't have a single float (i.e., use only integer variables and computations).
Hope this helps.