Guest User

Untitled

a guest
Sep 13th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. function findSolution(target) {
  2. function find(start, history) {
  3. if (start == target)
  4. return history;
  5. else if (start > target)
  6. return null;
  7. else
  8. return find(start + 5, "(" + history + " + 5)") ||
  9. find(start * 3, "(" + history + " * 3)");
  10. }
  11. return find(1, "1");
  12. }
  13.  
  14. console.log(findSolution(8));
Add Comment
Please, Sign In to add comment