let n=0
let x=0
function func(arr,k){
for(let i=0;
i<arr.length;i++)
{
if(n===arr[i]){
x++
for(let i=0;
i<arr.length;i++)
{
if(n+arr[i]===k){
console.log(n)
console.log(arr[i])
return true
}}}}
if(x<arr.length){
n++
func(arr,k)
}
if(x>=arr.length){
return false
}
}
console.log(func([11,25,34,46,5],59))
const hasPairSum = (nums, desiredValue) => {
if(nums.length < 2) {
return false;
}
const [firstNum, ...tailNums] = nums;
const hasDesiredValue = tailNums.some((num) => firstNum + num === desiredValue);
return hasDesiredValue || hasPairSum(tailNums, desiredValue);
};