Advertisement
Guest User

Problema somma array

a guest
Oct 14th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fn (min, max, array, num) {
  2.   if (min === max ) { return false; }
  3.   const tot = array[min] + array[max];
  4.   if (tot === num) {
  5.     return true;
  6.   } else if (tot < num) {
  7.     return fn (min + 1, max, array, num);
  8.   } else {
  9.     return fn (min, max - 1, array, num);
  10.   } // if - else
  11. } // fn
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement