0

Hi..
I want to make following series..
I try a lot but i am having confusion in loops. so please help me.

1
212
32123
4321234
So any one have idea about this .

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by diafol
0

Increments and decrements, decisions, decisions! This can be done in a reasonably painless way with just a single increment. However, as MS says, show us yer code!

0

I have write this code.. but it is simple one.

<?php
for($a=1 ; $a<=5; $a++)
{
    for($b=5; $b>$a; $b--)
    {
        echo ".";
    }

    for($i=($a*2-1); $i>=1; $i--)
    {
        echo $i;


    }
    echo "<br>";
}
?>

Edited by Reverend Jim: Fixed formatting

0

Nah, you just need to keep copying the previous answer and apply the next number front and end.

e.g. current number is 32123 (3rd go)
next number is 4 (4th go) & last number & 4 (4th go)
etc.

Don't know if that makes sense. Didn't want to give you the whole thing. I'd start with a default value of 1 for the output and then start incrementing on counter = 2.

Edited by diafol: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.