开发者

PHP Riddle. The function of the pyramid [closed]

开发者 https://www.devze.com 2023-02-09 13:37 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
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

精彩评论

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