开发者

how many times will a function print to the console? [closed]

开发者 https://www.devze.com 2023-04-02 08:16 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about programming within the scope defined in the help center.

Closed 9 years ago.

开发者_如何学Python Improve this question

I have the following snipet :

public class A

public A(int n)
{
    for (int i=0; i<n; i++)
    {
        new A(i)
    }
    console.writeln("?")
}

for a given n - how many "?" will be printed ?

  • some testing shows the answer is 2^n. What is the way to reach the formula?
  • I got to the formula F(n) = 1 + F(n-1) +... +F(1) + 1

how do I simplify it to 2^n ?


If you cannot simplify it, perhaps you can prove it by induction.

http://en.wikipedia.org/wiki/Mathematical_induction

I don't know if this question is pertinent here... it has more to do with maths than with programming.

0

精彩评论

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