@gajendra i found that its basically combination problem we have to print all combination of all number in given range that can compose a given number
Examples: For n = 1, the program should print following: 1 For n = 2, the program should print following: 1 1 2 For n = 3, the program should print following: 1 1 1 1 2 2 1 3 For n = 4, the program should print following: 1 1 1 1 1 1 2 1 2 1 1 3 2 1 1 2 2 3 1 and so on … Algorithm: At first position we can have three numbers 1 or 2 or 3. First put 1 at first position and recursively call for n-1. Then put 2 at first position and recursively call for n-2. Then put 3 at first position and recursively call for n-3. If n becomes 0 then we have formed a combination that compose n, so print the current combination You Can Find generalized Code here You Can make it Customize acc. to your recq. http://codepad.org/uw2K9a2c Thanks & Rergards Shashank Mani >> "The best way to escape from a problem is to solve it." -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.