// 求百钱百鸡
function buy(ind, indexs, start) {
start++;
if (start > 2) {
return;
}
if (!indexs[start]) {
indexs[start] = 0;
}
for (indexs[start] = ind; indexs[start] <= 100; indexs[start]++) {
buy(0, indexs, start); // 递归调用
if (start == 2) {
if (5 * indexs[start – 2] + 3 * indexs[start – 1] + indexs[start] * 1 / 3 == 100
&&
indexs[start – 2] + indexs[start – 1] + indexs[start] == 100
) {
console.info(“公鸡:” + indexs[start – 2] + “母鸡:” + indexs[start – 1] + “小鸡:” + indexs[start]);
break;
}
}
}
}
buy(0, {}, -1);