Re: [algogeeks] Re: perfect square condition checking....

2013-01-14 Thread Dave
@Bharat: It can be proven that Newton's method for square root, x(n+1) = (x(n) + a / x(n))/2, always converges to sqrt(a) if a > 0 and x(0) > 0. It is not difficult, so let e(n) = x(n) - sqrt(a), the error in the n-th iteration, and find the recurrence for e(n+1) in terms of e(n) and a. You sho

[algogeeks] Re: Amazon Dynamic Programming problem

2013-01-14 Thread Don
This problem was a team challenge in Survivor Amazon, except they were allowed to take 1,2,3, or 4 flags. The winning strategy is to leave a multiple of 5 flags. But none of the contestants figured it out. Don On Jan 12, 8:03 am, siva wrote: > consider there are N balls in a basket. 2 players pla

[algogeeks] Re: Amazon Dynamic Programming problem

2013-01-14 Thread Don
If it is your turn and there are 1 or 2 balls in the basket you take them and win. If it is your turn an there are 3 balls in the basket, you must leave 1 or 2 after your turn, so you lose. If the number of balls on your turn is not divisible by 3, you can take 1 or 2 balls and make it divisible by

[algogeeks] Re: perfect square condition checking....

2013-01-14 Thread Don
Can you show me a case where it diverges if the initial guess is half the digits of X? Don On Jan 14, 3:09 am, bharat b wrote: > @Don : But, newton's formulae doesn't always converge.. if our guess is bad > enough, it may diverge also. > > > > > > > > On Tue, Jan 8, 2013 at 8:30 PM, Don wrote: >

Re: [algogeeks] Re: perfect square condition checking....

2013-01-14 Thread bharat b
@Don : But, newton's formulae doesn't always converge.. if our guess is bad enough, it may diverge also. On Tue, Jan 8, 2013 at 8:30 PM, Don wrote: > Sure, > > Let's try two examples: > x=1,038,381,081 > > The last digit is 1, so continue > Now start with y=10,000 because that is half as many di