PHP Riddle. The function of the pyramid [closed]
I have a riddle for you.
I need a function that displays the number of pyramid structures.
Example: echo getNumber(7)
Output: 12345677654321
In this case, do not use outside functions and operators.
From the mathematical symbols use only addition. Dont use for/while/implode/range/count.
Maximum use of one condition.
Good luck!
The answer to your assignment IS RECURSION.
Take a look, and good luck.
I do not want to give you the answer as others take shame upon that. But here is an example of how you would get 7654321 with a recursive function.
function getNumbers(int val) {
if val != 0
{
echo val;
val = val -1;
getNumbers(val)
}
}
精彩评论