MadelineProto/sqr.php

17 lines
278 B
PHP
Raw Normal View History

<?php
2016-07-30 16:14:47 +02:00
function mysqr($n)
{
$guess = $n / 2;
while (true) {
$last = $guess;
$guess = (($n / $guess) + $guess) / 2;
2016-07-30 16:14:47 +02:00
if ($last == $guess) {
break;
}
}
2016-07-30 16:14:47 +02:00
return $guess;
}
2016-07-30 16:14:47 +02:00
var_dump(mysqr(234892482328), sqrt(234892482328));