Integer roots: Difference between revisions

Content added Content deleted
mNo edit summary
Line 116: Line 116:
0.5
0.5
</pre>
</pre>

=={{header|Scheme}}==
{{trans|Python}}
<lang scheme>(define (root a b)
(define (y a a1 b c d e)
(if (or (= c d) (= c e))
(if (< d e) d e)
(y a a1 b d e (quotient (+ (* a1 e) (quotient b (expt e a1))) a))))
(if (< b 2)
b
(let* ((a1 (- a 1))
(c 1)
(d (quotient (+ (* a1 c) (quotient b (expt c a1))) a))
(e (quotient (+ (* a1 d) (quotient b (expt d a1))) a)))
(y a a1 b c d e))))
(display "First 2,001 digits of the square root of two:\n")
(display (root 2 (* 2 (expt 100 2000))))</lang>



=={{header|zkl}}==
=={{header|zkl}}==