wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> easy >> Rounded Roots
(Message started by: Sir Col on Jun 28th, 2003, 3:16am)

Title: Rounded Roots
Post by Sir Col on Jun 28th, 2003, 3:16am
A special number machine will accept any natural number, find its square root and then output the result rounded to the nearest whole number.

For example,
32 — square root —> 5.656... — rounded —> 6

1. If 6 is the output, what is the set of possible input numbers?

2. For a given output, n, find the set of possible input numbers.

3. Prove your result.

Title: Re: Rounded Roots
Post by TenaliRaman on Jun 28th, 2003, 8:32am
1>[Hide] Inputs={x|31<=x<=42} [/Hide]

2>[Hide] Inputs={x|((n-1)2+k)<=x<=(n2+k)}
where k = floor((4n-3)/4)+1[/Hide]

3>[Hide]
note that all such number will be greater than (n-1)2
our inputs will be simply determined by an offset from (n-1)2.Take this offset as k,

Then it is easy to note that,
sqrt((n-1)2+k)>(n+(n-1))/2

solving this for k gives the answer.
[/Hide]

Title: Re: Rounded Roots
Post by Sir Col on Jun 28th, 2003, 9:36am
Nice solution, TenaliRaman. What a clever and original approach too. Having done the hardest part, you might like to simplify it, as you don't need the floor function. Consider: [hide] sqr((n–1)2+k)>=n–0.5 [/hide] ;)

Title: Re: Rounded Roots
Post by TenaliRaman on Jun 28th, 2003, 10:04am
D'oh!! ofcourse !!!
[hide]k = floor((4n-3)/4)+1 = floor(n-3/4)+1 = n - 1 + 1 = n[/hide]

P.S->[Hide] yes ofcourse my avatar.(should've noticed that!!)[/Hide]

This P.S should've been in the other topic  ;D

Title: Re: Rounded Roots
Post by Sir Col on Jun 28th, 2003, 10:12am
What if the number machine cube roots?
(I've not solved this myself yet)

P.S. [hide]Oh well, it'll add a bit of intrigue (and confusion) for anyone who's not read the other topic – especially as they don't know what the other topic or the question was.[/hide]  ;D

Title: Re: Rounded Roots
Post by TenaliRaman on Jun 28th, 2003, 10:54am
i followed the same approach as above for the cube root which gives,
[Hide] k = floor( (12n2-18n+7)/8 )+1 [/Hide]
Simplification of this though seems difficult.




Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board