If you can understand the last example, you should be able to understand rule number 3.
What does 33289 produce?
- What does 3289 produce?
-- What does 289 produce?
--- 89
-- 289 produces 89, so 3289 produces the associate of 89 or 89289
- 3289 produces 89289, so 33289 produces the associate of 89289 or 89289289289
I dont think so , Jan. The rule said, 2X will produce X. So 2222 should produce 222. For every string containing no '0' and starting with '2' , the output shall be the resulting string found by removing the '2' at the beginning.
Raiyan Kamal wrote:I dont think so , Jan. The rule said, 2X will produce X. So 2222 should produce 222. For every string containing no '0' and starting with '2' , the output shall be the resulting string found by removing the '2' at the beginning.
I think you have misunderstood something. The problem states...
Rule 1:
Given any number X not containing a digit zero, then number 2X produces X. For example, 234 produces 34.
There is no rule saying that you have to do recursive calculation with X in the cases like 2X. And I did not code my program ( whic produced an AC long ago ) that way. My prog gives 222 if input is 2222.
Thnx Helloneo...
I misunderstood the problem.I was checking from the end of number and repeating the process recursively as Jan explained.For example:For input 323289
at first i found x=289 which results Y=89 and as according to rule 3 it produces 89289 .So number becomes 3289289...recursively again I got X=289289 which results Y=89289 and finally again from rule 3 i got the final output 89289289289.That's the way i worked.But got that my approach is wrong...Please can u explain how 33289 produces 89289289289
Tn\hnx again
Imti wrote:Thnx Helloneo...
I misunderstood the problem.I was checking from the end of number and repeating the process recursively as Jan explained.For example:For input 323289
at first i found x=289 which results Y=89 and as according to rule 3 it produces 89289 .So number becomes 3289289...recursively again I got X=289289 which results Y=89289 and finally again from rule 3 i got the final output 89289289289.That's the way i worked.But got that my approach is wrong...Please can u explain how 33289 produces 89289289289
Tn\hnx again
Well, the example of 33289 is pretty much explained by UFP2161..
See the previous post..
BTW, for the input 323289, I think x = 3289, not 289. Which means 323289 => 3(23289) => 3(2(3289)) => 3(3289) => 328923289