My issue
My code is throwing a runtime error when I try to use the bcadd function of PHP to add two integers. How can I add two large numbers in PHP? Please help.
My code
<?php
$t = readline();
for($i = 0; $i < $t; $i++) {
$n = readline();
$a = explode(' ', readline());
$val = $n;
for($j = 0; $j < $n; $j++) {
if($val < $a[$j]) {
$val += $a[$j] - $val;
}
$val--;
}
print(bcadd($val, $n) . PHP_EOL);
}
Problem Link: Walk Practice Coding Problem - CodeChef