3v4l.org

run code in 300+ PHP versions simultaneously
<? class BigAndSmallStep { public $f; public $b; public $n; public $a; public $L1 = array(); public $L2 = array(); public $findStr; public $result; public function __construct ($f, $b, $n) { $this->f = intval($f); $this->b = intval($b); $this->n = intval($n); $this->a = self::countA($this->n); } function countA($n) { return ceil(sqrt($n)); } function countL1() { $c = $this->a-1; $i = 0; while ( $i <= $c) { $heig = $i * $this->a; //echo $heig."<br/>"; $this->L1[$i] = array($i, $heig, self::countResL1($heig)); $i++; } return true; } function countL2() { $c = $this->a; $i = 0; while ( $i <= $c) { $this->L2[$i] = array($i, self::countResL2($i)); $i++; } return true; } function mod($x, $y) { return fmod($x, $y); } function countResL1($heig) { $number = pow($this->f, $heig); //echo $number."<br>"; return self::mod( $number, $this->n); } function countResL2($heig) { $number = $this->b * (pow($this->f, $heig)); //echo $number."<br>"; return self::mod( $number, $this->n); } function searchRes() { $c = count($this->L1)-1; $i = 0; while ( $i<= $c) { $ser = $this->L1[$i][2]; $res = self::searchValueInL2($ser); if($res !== false) { return $this->findStr = $i."_".$res; } $i++; } return false; } function searchValueInL2($value) { $c = count($this->L2)-1; $i = 0; while ( $i <= $c) { if($this->L2[$i][1] == $value) { return $i; } $i++; } return false; } function finalResult() { $elem = split("_", $this->findStr); $first = self::mod($this->b, $this->n); $heig = $this->L1[$elem[0]][1] - $this->L2[$elem[1]][0]; $this->result = ceil(self:: mod ( pow($this->f,$heig), $first)) ; } function showRiv() { $elem = split("_", $this->findStr); $f_h = ($this->L2[$elem[1]][0] != 1) ? $this->L2[$elem[1]][0] : ' '; echo " ".$this->b." * ".$this->f. "<sup><small>".$f_h."</small></sup> = ". $this->f."<sup><small>".$this->L1[$elem[0]][1]. "</small></sup> mod ". $this->n; } function getResult() { return $this->result; } } $alg = new BigAndSmallStep(2, 11, 13); if ( ($alg->countL1() != false) && ($alg->countL2() !=false )){ $alg->searchRes(); $alg->finalResult(); $alg->showRiv(); echo "<br/> Result x = ".$alg->getResult(); } else echo "Ошибочка =("; ?>
Output for git.master, git.master_jit, rfc.property-hooks
<? class BigAndSmallStep { public $f; public $b; public $n; public $a; public $L1 = array(); public $L2 = array(); public $findStr; public $result; public function __construct ($f, $b, $n) { $this->f = intval($f); $this->b = intval($b); $this->n = intval($n); $this->a = self::countA($this->n); } function countA($n) { return ceil(sqrt($n)); } function countL1() { $c = $this->a-1; $i = 0; while ( $i <= $c) { $heig = $i * $this->a; //echo $heig."<br/>"; $this->L1[$i] = array($i, $heig, self::countResL1($heig)); $i++; } return true; } function countL2() { $c = $this->a; $i = 0; while ( $i <= $c) { $this->L2[$i] = array($i, self::countResL2($i)); $i++; } return true; } function mod($x, $y) { return fmod($x, $y); } function countResL1($heig) { $number = pow($this->f, $heig); //echo $number."<br>"; return self::mod( $number, $this->n); } function countResL2($heig) { $number = $this->b * (pow($this->f, $heig)); //echo $number."<br>"; return self::mod( $number, $this->n); } function searchRes() { $c = count($this->L1)-1; $i = 0; while ( $i<= $c) { $ser = $this->L1[$i][2]; $res = self::searchValueInL2($ser); if($res !== false) { return $this->findStr = $i."_".$res; } $i++; } return false; } function searchValueInL2($value) { $c = count($this->L2)-1; $i = 0; while ( $i <= $c) { if($this->L2[$i][1] == $value) { return $i; } $i++; } return false; } function finalResult() { $elem = split("_", $this->findStr); $first = self::mod($this->b, $this->n); $heig = $this->L1[$elem[0]][1] - $this->L2[$elem[1]][0]; $this->result = ceil(self:: mod ( pow($this->f,$heig), $first)) ; } function showRiv() { $elem = split("_", $this->findStr); $f_h = ($this->L2[$elem[1]][0] != 1) ? $this->L2[$elem[1]][0] : ' '; echo " ".$this->b." * ".$this->f. "<sup><small>".$f_h."</small></sup> = ". $this->f."<sup><small>".$this->L1[$elem[0]][1]. "</small></sup> mod ". $this->n; } function getResult() { return $this->result; } } $alg = new BigAndSmallStep(2, 11, 13); if ( ($alg->countL1() != false) && ($alg->countL2() !=false )){ $alg->searchRes(); $alg->finalResult(); $alg->showRiv(); echo "<br/> Result x = ".$alg->getResult(); } else echo "Ошибочка =("; ?>

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
35.68 ms | 409 KiB | 8 Q