编写一个程序,得到N个正非零整数,使这些数字的和和和乘积相等


Write a program to get N number of positive non-zero integers, so that the sum and product of these numbers are equal

假设数字是A, B, C, D and E

所以,我想要的是

A + B + C + D + E = A * B * C * D * E

我想写一个程序(最好是PHP)来解决它

注意:数字可以重复。例如,我们可以使用A, B, B, D and E

是。我自己解决了。

答案是个数2(个数-2)的1s

比方说,如果我们考虑5个数字,它们将是5、2、1、1和1。

如果我们考虑6个数字,它们将是6、2、1、1和1。

这是php程序-

<?php
$n = 5;
$numbers = array();
$numbers[] = $n;
$numbers[] = 2;
for($i=1; $i<=($n-2); $i++){
    $numbers[] = 1;
}

$numbers数组将包含数字!