开发者

PHP Riddle. The function of the pyramid [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago. 开发者_运维问答

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)
}


}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜