# need a help to do this Question

• December 7th, 2013, 11:32 PM
Supun Pramoda
need a help to do this Question
I tried to do this question.But I can't take a right approach. This is the question:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
It can be seen that the number, 125874 and its double ,251748 contain exactly the same digits,but in a different order.Write a java program to find to find & print the smallest positive integer "x",such as "2x,3x,4x,5x and 6x" contain the same digits.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~

I need to do it only using Arrays.(except in String method & regex).
• December 8th, 2013, 01:04 AM
GregBrannon
Re: need a help to do this Question
Show what you've tried. Start simple with the 2x and 3x case and then expand from there.
• December 8th, 2013, 07:21 AM
Supun Pramoda
Re: need a help to do this Question
I haven't clear idea to solve this this question.can you help me to do that??:confused:
• December 8th, 2013, 07:27 AM
GregBrannon
Re: need a help to do this Question
For the simplified approach (2x/3x only), the brute force method would be to start with x = 1, multiply by 2 and 3 to get 2x and 3x and then check if 2x and 3x contain the same digits. If x = 1 is not the 2x/3x answer, then repeat with x + 1. Continue repeating until the 2x/3x answer is found.

What part of this approach didn't occur to you and/or are you unable to program? Pretty basic stuff if you think it through. Maybe writing your ideas down on paper or electronic notepad first would be helpful. That's kind of what I was doing here as I explained it to you.
• December 8th, 2013, 08:13 AM
Supun Pramoda
Re: need a help to do this Question
ok. I think the the minimum number must be contain more than 6 digits.So I want to check each number digit by digit until find the minimum number.I want to create an Array to do that.But I can't construct it?I need a code to do that:confused:
• December 8th, 2013, 09:05 AM
GregBrannon
Re: need a help to do this Question
I recommend you review the Arrays Tutorial. We won't give you code, but we'll help you with code you've written.