I have a number 0127
i am trying logic to generate number following sequence in JAVA
0
1
2
7
01
12
27
012
127
0127
1270
2701
7012
01270
12701
27012
.
.
I am breaking my head 🙂
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.
I would convert the number to a
Stringobject, then to an array of chars.From there, you can iterate over the array with the following logic:
Change
MAX_LENGTHto be what ever the maximum length of the output string should be.Here is the output that this code produces:
