This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Function to generate fibonacci sequence that contains large numbers | |
function getFibonacci() { | |
$i = '0'; | |
$k = '1'; //first fibonacci value | |
yield $k; | |
while(true) { | |
// gmp_add to add two gmp number (www.php.net/manual/en/ref.gmp.php) | |
$k = gmp_add($i, $k); | |
// gmp_subtract to subtract $i from $k |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function find_highest_prime_factor($n) | |
{ | |
for ($i = 2; $i <= $n; $i++) | |
{ | |
if (bcmod($n, $i) == 0) //its a factor | |
{ | |
return max($i, $this->find_highest_prime_factor(bcdiv($n,$i))); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Function to generate fibonacci sequence that contains large numbers | |
function getFibonacci() { | |
$i = '0'; | |
$k = '1'; //first fibonacci value | |
yield $k; | |
while(true) { | |
// gmp_add to add two gmp number (www.php.net/manual/en/ref.gmp.php) | |
$k = gmp_add($i, $k); | |
// gmp_subtract to subtract $i from $k |