<?php
$n = 3;
$sum = 10;
findNDigitNums($n, $sum);
function findNDigitNums($n, $sum)
{
$out = array_fill(0, $n + 1, false);
for ($i = 1; $i <= 9; $i++)
{
$out[0] = chr($i + ord('0'));
findNDigitNumsUtil($n, $sum - $i, $out, 1);
}
}
function findNDigitNumsUtil($n, $sum, $out, $index)
{
if ($index > $n || $sum < 0)
return;
if ($index == $n)
{
if($sum == 0)
{
$out[$index] = '';
foreach ($out as &$value)
print($value);
print(" ");
}
return;
}
for ($i = 0; $i <= 9; $i++)
{
$out[$index] = chr($i + ord('0'));
findNDigitNumsUtil($n, $sum - $i, $out, $index + 1);
}
}
?>
❤️❤️ Hello Henry ❤️❤️ I hope you are doing well and safe from COVID-19. I read your requirements very carefully and understand your needs. This work really attracts me, and I have done similar work before, so I have rich experiences and good knowledge over 6+ years working with Laravel, PHP, MySQL, BOOTSTRAP, jQuery, HTML5, CSS3. I can start work immediately and can deliver high-quality results inside the deadline. Please discuss in more detail about the project via chat. Best regards.
Thanks again.