Please help me with this equation... can't solve it

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kee2ka4
    New Member
    • May 2007
    • 2

    Please help me with this equation... can't solve it

    What initial values of a and c are required such that the final values of a and b are:

    a = 32
    b = 4



    int a,b,c

    a = ?
    b = 0
    c = ?

    for( b=0; a<12; b++ )
    {
    a = (a+a) * c;
    }


    I have tried working it out but at loop 3 (b=3) I keep getting the value of a as 16 which is greater then 12. This is when I assume that a is 1 and c is 1 but it doesn't work.

    Any help appreciated.

    Kind Regards
  • rsrinivasan
    New Member
    • Mar 2007
    • 221

    #2
    Originally posted by kee2ka4
    What initial values of a and c are required such that the final values of a and b are:

    a = 32
    b = 4



    int a,b,c

    a = ?
    b = 0
    c = ?

    for( b=0; a<12; b++ )
    {
    a = (a+a) * c;
    }


    I have tried working it out but at loop 3 (b=3) I keep getting the value of a as 16 which is greater then 12. This is when I assume that a is 1 and c is 1 but it doesn't work.

    Any help appreciated.

    Kind Regards

    Hi,
    The final value of a=32 and b=4, when a=32 and c=1. But one condition you should change the for loop condition as "a<17" instead of "a<12".

    Thanks,
    Srinivasan r.

    Comment

    • Ganon11
      Recognized Expert Specialist
      • Oct 2006
      • 3651

      #3
      I think the problem is that the only values kee2ka4 can choose are a and c - the loop, conditions, expressions, and final results cannot be manipulated.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by rsrinivasan
        Hi,
        The final value of a=32 and b=4, when a=32 and c=1. But one condition you should change the for loop condition as "a<17" instead of "a<12".
        That's cheating! ;-) There's no need to change that loop condition.
        Here's the problem again:[code=java]
        a = 32
        b = 4



        int a,b,c

        a = ?
        b = 0
        c = ?

        for( b=0; a<12; b++ )
        {
        a = (a+a) * c;
        }[/code]

        The final value of a == 32. So the expression (a+a)*c= 2*a*c must be a power
        of two (because 32 is a power of two). So a*c must be a power of two. Every
        value of a_n == 2^n*a_0*c^n where a_0 is the initial value of a and a_n is the
        last value of a (== 32).

        2^(n-1)*a_0*c^(n-1) should be less than 12 (by the condition), so 2*c should be
        at least equal to 4 (c in [2, 4, 8, 16]) and the accompanying values of a are
        in [8, 4, 2, 1].

        kind regards,

        Jos

        Comment

        • jaiminpsoni
          New Member
          • Sep 2007
          • 2

          #5
          The answer is

          a=2
          c=-1

          Comment

          Working...