 All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars  perplexus dot info  Summing up (Posted on 2016-08-17) Evaluate the value of
SUMn=1 to 2016 ((-1)n*int (sqrt(n)))

 See The Solution Submitted by Ady TZIDON No Rating Comments: ( Back to comment list | You must be logged in to post comments.) solution | Comment 1 of 2
sqrt(2016) is 44 plus a fraction so only absolute values to 44 need be considered.

Consider the first few:

1         -1
2         1
3         -1
4         2
5         -2
6         2
7         -2
8         2
9         -3
10        3
11        -3
12        3
13        -3
14        3
15        -3
16        4
17        -4
18        4

There are 3 with absolute value 1, 5 with abs value 2, 7 with abs value 3, etc.  They alternate excess negative and excess positive, so the sum will be -1 + 2 - 3 + 4 - 5 + ...

The term with absolute value 44 might be an exception to the sign implied by the above as the sequence of positives and negatives is arbitrarily stopped in the middle of its run (well, not necessarily exactly in the middle, but somewhere within the alternating + and -).

The first abs value of 44 occurs at n = 44^2 = 1936 and ends at 2016, also even and therefore a +44, so indeed the 44 has a positive sign, for an excess of one +44 over -44.

Each negative/positive pair has a value of +1, and there are 22 such pairs, so the total is 22.

Verification is made by the following code snippet:

preface = -1
For n = 1 To 2016
tot = tot + preface * Int(Sqr(n))
preface = -preface
Next

Text1.Text = Text1.Text & crlf & tot & " done"

 Posted by Charlie on 2016-08-17 14:33:35 Please log in:

 Search: Search body:
Forums (0)