My issue
How can I perform the addition of very large numbers in PHP. I get an error message when I try to use the bcmath function to do so.
My code
<?php
for($i = 0; $i < 10; $i++) {
$n = readline();
if($n == false) {
break;
} else {
$x = floor($n / 2);
$y = floor($n / 3);
$z = floor($n / 4);
$sum = bcadd($x + $y + $z);
print(max($sum, $n) . PHP_EOL);
}
}
Problem Link: COINS Problem - CodeChef