While loop question

Hi all. I am trying to write an iteration loop using while loop but it returns nothing. I'm interested in returning b where depends on its previous value and the values of u and v which are also generated by this loop. I have the 1st value of u = mean

m <- 1
b <- mean(x)
#U <- 0
#V <- 1

while(m<=5){
  print (b)
  u = -(56/b) + (sum(x^2)/b^2)
  print(u)
  v = 56/b^2 - (2*sum(x^2)/b^3)
  print(v)
  b = b - (u/V)
}

There are some issues with your loop.
m, the condition of your loop is not modified within your loop, so the loop will never complete.
You also have a division by capital V though this is undefined and your lowecase v is unused

1 Like

Yes you're correct about this. I have updated and now its giving wrong values not sure why.

Thank you. This was very helpful

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.