0

So this problem is pretty nasty. I can easily find the number of iterations for each nested while loop. The first runs log_9(n) times and the second runs log_4(n) times. My problem that I do not know how to address is the initialization of i = n. I'm quite lost on this part so anything helps!

function p(n)
    i = n;
    while i < 5n^3 do
        x = 7n^2;
        while x < 6
            x = x/9;
        end
        i = 4i;
    end
  • Welcome to CS.SE! This is a fairly standard kind of question. What have you tried? We have many questions on analyzing nested loops on this site that describe techniques to analyze this. Try using search in the upper-right-hand corner, or look at the "related" list to the right. Let me direct you towards our reference questions which cover your problem in detail. If you study all of those techniques and find that they don't solve your problem, please edit it to explain what research you've done and what you've tried. – D.W. Oct 19 '15 at 06:34
  • Lastly, a hint: Try editing the question to explain your reasoning for how you got the number of times each loop iterates. If you try working through it in detail and explaining your reasoning, I suspect you might be able to figure out how to answer your question about i=n yourself. – D.W. Oct 19 '15 at 06:37
  • "while x < 6 | x = x/9 | end" behaves in a very interesting way which would make me immediately believe that there is a bug. – gnasher729 Nov 08 '16 at 10:58

0 Answers0