In my case there was multiplication . But I have no problem with the edit. I just want to know how to approach in case of backtracking. Because with backtracking in case of n=10 then output will be too slow.