is there any way with which we can print the following pattern? :         class pattern
        {
            public static void main()
            {
                int i,j,p=1;
                for(i=1;i<=5;i++)
                {
                    for(j=1;j<=i; j++)
                    {
                       System.out.print(p+" ");
                       p=p+2;
                    }
                    if(i>=2)
                    p=p-2;
                   System.out.println ();
                }
            }
        }
    i want the below written output 
    
    1
    3 5
    5 7 9
    7 9 11 13
    9 11 13 15 17
    
    but the output obtained by the above written code is given below
    1
    3 5 
    5 7 9
    9 11 13 15 
    15 17 19 21 23

i want last digit of second row to be displayed at the starting of third row and last two digits of third row to be displayed in the beginning of the fourth row and so on.