Skip to content

Instantly share code, notes, and snippets.

@abdulhalim-cu
Created October 25, 2017 10:17
Show Gist options
  • Save abdulhalim-cu/ee00ac9abe303003a040cedb6b7d9f6c to your computer and use it in GitHub Desktop.
Save abdulhalim-cu/ee00ac9abe303003a040cedb6b7d9f6c to your computer and use it in GitHub Desktop.
function findSolution(target) {
function find(current, history){
if (current == target)
return history;
else if (current > target)
return null;
else
return find(current + 5, "(" + history + " + 5)") ||
find(current * 3, "(" + history + " * 3)");
}
return find(1, "1");
}
console.log(findSolution(29))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment