title: I am giving here a O/P. I need the code using PHP and JAVA
body: <p>This is clearly an interview question which ask by a interviewer today. I can't get the solution. Hope SOF will help me..</p>
  
  <p><strong>O/P</strong></p>
  
  <blockquote>
    <p>1</p>
    
    <p>12</p>
    
    <p>123</p>
    
    <p>12</p>
    
    <p>1</p>
  </blockquote>
  
  <p>what is the code?</p>
  
  <p>this should be done by both PHP and JAVA. And if it's possible kindly explain me the logic also.</p>
  
  <p>thanks in advance</p>