Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 651 Bytes

p0080.md

File metadata and controls

28 lines (19 loc) · 651 Bytes

[<] [^] | [>]

Problem 80: Square root digital expansion

The link to the problem

My approach

First I used a method of extracting square root which I was taught in my childhood. The problem was solved, but it was very tedious.

I therefore solved it by arbitrary-precision arithmetic.

$$ \begin{align} \large i & \le 10^{99} \sqrt{n} < i + 1 \\ \therefore i^{2} & \le 10^{198} n < (i + 1)^{2} \end{align} $$

For example, in the case of $\sqrt{2}$

>>> sum(map(int, list(str(math.isqrt(10**198 * 2)))))
475