Generate all lists of size n, such that each element is between 0 and m (inclusive).
There are (m+1)^n such lists.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are two easy ways of writing the general case. One is described in the existing answer from @didierc. The alternative is recursion.
For example, think about a method that takes a String as an argument: