text:
The shifting dot
Your program has to print out a number of spaces, followed by a dot and a newline.
The number of spaces is the x position of your dot defined with 0 < x < 30
Every new line is a turn. Your program runs for 30 turns. Your program starts with a random x position and every turn shifts this position randomly by 1 to the left or right, while staying inside the defined area. Every turn your dot has to change its position by 1.
Your score is the number of characters. You get 10 bonus points, if every printed line consists of exactly 30 characters (and newline). You get 50 bonus points, if, while random, your program tends to stay in the middle of the defined area.
Edit:
The 50 bonus points are intended to pull your dot to the middle. For example, this apply's if your dot is at x=20 and has a chance of 66% to go left and 33% to go right. This has to be independent from starting point and should only happen by altering the percentage value of left/right dynamically.
No input of any kind allowed, output has to be on the executing console!
For better understanding, here is a readable example in java, that would give you a score of 723:
public class DotJumper{
    public static void main(String[] args){
        int i = (int)(Math.random()*30);
        int max = 29;
        int step = 1;
        int count = 30;
        while(count>0){
            if(i<=1){
                i+=step;
            }else if(i>=max){
                i-=step;
            }else{
                if(Math.random() > 0.5){
                    i+=step;
                }else{
                    i-=step;
                }
            }
            print(i);
            count--;
        }
    }
    public static void print(int i){
        while(i>0){
            System.out.print(' ');
            i--;
        }
        System.out.println('.');
    }
}

In your example, I think that the int i = (int)(Math.random()*30); should be int i = 1 + (int)(Math.random()*29); instead. As is, it generates a number 0 >= x > 30 instead of 0 > x > 30.

I think original code is correct.

it is correct, because i shift first and the print. so even if the random value exceeds the border, if will first correct and then print.

@Kostronor But this implies that the starting dot position does not follows an uniform distribution, the first position is twice as probably than the other positions. OTOH, being uniformly distributed was not a requirement either.

Seems like it would be harder to create a program where the dot jumps around more. So why is there a bonus for restricting its movement?

It should be noted that the consensus is now that bonuses should not be allowed in code-golf.

APL, 39 – 10 – 50 = –21
0/{⎕←30↑'.',⍨⍵↑''⋄⍵+¯1*⍵>.5+?28}/31/?29

Tested on Dyalog with ⎕IO←1 and ⎕ML←3 but it should be quite portable.
Explanation
                   ?29  take a random natural from 1 to 29
                31/     repeat it 31 times
              }/        reduce (right-fold) the list using the given function:
          ⍵↑''          . make a string of ⍵ (the function argument) spaces
     '.',⍨              . append a dot to its right
⎕←30↑                   . right-pad it with spaces up to length 30 and output
                ◇       . then
             ?28        . take a random natural from 1 to 28
          .5+           . add 0.5, giving a number ∊ (1.5 2.5 ... 27.5 28.5)
        ⍵>              . check whether the result is <⍵ (see explanation below)
     ¯1*                . raise -1 to the boolean result (0 1 become resp. 1 -1)
   ⍵+                   . add it to ⍵ and return it as the new accumulator value
0/{                     finally ignore the numeric result of the reduction

At every step, this code decides whether to move the dot to the left or to the right depending on the probability that a random number chosen among (1.5 2.5 ... 27.5 28.5) is less than the current dot position.
Therefore, when the current dot position (number of spaces to the left) is 1 the increment is always +1 (all of those numbers 1.5 ... 28.5 are > 1), when it's 29 it's always -1 (all of those numbers are < 29); otherwise it's chosen randomly between +1 and -1, with a probability that's a linear interpolation between those extremes. So the dot is always moving and always more likely to move towards the center than towards the sides. If it's exactly in the middle, it has a 50% chance to move to either side.
The reduction (right-fold) of a replicated value {...}/a/b is just a trick I came up with to repeat a function a-1 times, starting with value b and having the result of each iteration be the accumulator (⍵) argument to the next. The second and next input arguments (⍺) as well as the final result are ignored. It turns out to be way shorter than a regular recursive call with guard.
Example run
0/{⎕←30↑'.',⍨⍵↑''⋄⍵+¯1*⍵>.5+?28}/31/?29
                   .
                    .
                   .
                  .
                 .
                .
               .
                .
               .
                .
               .
              .
             .
              .
             .
              .
               .
              .
               .
                .
                 .
                  .
                 .
                  .
                 .
                  .
                 .
                .
               .
                .

apl is a great language for golf (hard to read for me, though); UP!

@blabla999 APL has many common symbols and some strange ones, but once you learn their function the language is easy to read and write. Certainly easier that the ASCII noise of 'golfing' languages, but I'd venture to say it's even easier than regular languages. The syntax is very regular, you only have one rule: the expressions are executed from right to left, so that they can be read from left to right: +/2×⍳9 is read "the sum of: two times: the naturals up to 9" but is executed in the opposite way.

Is it me or is there 31 characters per line here?

I get 30, both by copy-pasting a line from the example run above into an editor, and by checking the code again. ⎕←30↑... will print 30  characters plus a newline, no matter what string is in ...

Mathematica 138 - 10 - 50 = 78
I'm not posting this because I think it's particularly well golfed, but for other reasons. It uses a Markov Process definition with a transition matrix designed to get the ball "centered".
The use of a Markov process in Mathematica allows us to calculate some useful statistics, as you will see below.
First the code (spaces not needed):
r = Range@28/28;
s = DiagonalMatrix;
ListPlot[RandomFunction[DiscreteMarkovProcess[RandomInteger@#, r~ s ~ -1 + s[29/28- r, 1]],
                                              #], PlotRange -> #] &@{1, 29}

Some outputs:

The transition matrix I used is:
MatrixPlot[s[r, -1] + s[29/28 - r, 1]]

But as I said, the interesting part is that using DiscreteMarkovProcess[] allows us to grab a good picture of what's happening.
Let's see the probability of the ball being at 15 at any time t starting from a particular random state:
d = DiscreteMarkovProcess[RandomInteger@29, s[r, -1] + s[29/28 - r, 1]];
k[t_] := Probability[x[t] == 15, x \[Distributed] d]
ListLinePlot[Table[k[t], {t, 0, 50}], PlotRange -> All]

You can see it fluctuates between 0 and a value near 0.3, that is because depending on the starting state you can only reach 15 on an odd or even number of steps :)
Now we can do the same thing, but telling Mathematica to consider the statistic starting from all possible initial states. What is the probability of being at 15 after a time t?:
d = DiscreteMarkovProcess[Array[1 &, 29]/29, s[r, -1] + s[29/28 - r, 1]];
k[t_] := Probability[x[t] == 15, x \[Distributed] d]
ListLinePlot[Table[k[t], {t, 0, 100}], PlotRange -> All]

You can see it also oscillates ... why? The answer is simple: in the interval [1, 29] there are more odd than even numbers :)
The oscillation is almost gone if we ask for the probability of the ball being at 14 OR 15:

And you could also ask for the limit (in the Cesaro sense) of the state probabilities:
ListLinePlot@First@MarkovProcessProperties[d, "LimitTransitionMatrix"]

Oh, well, perhaps I deserve some downvotes for such an off-topic answer. Feel free.

This isn't the shortest but it's really cool.

Upvoted, and now your score is no longer 2,222...

@cormullion Thanks! You can undo that by downvoting hard:)

Bash, score 21 (81 bytes - 50 bonus - 10 bonus)
o=$[RANDOM%28];for i in {D..a};{ printf " %$[o+=1-2*(RANDOM%29<o)]s.%$[28-o]s
";}

In this answer, the dot is "pulled" back to the middle.  This can be tested by hardcoding the starting point at 0 or 30.

Good solution! But please do not hardcode the starting point ;)

@Kostronor - oops - I missed that, and have now fixed it.

save a char by replacing {1..30} by {P..m}

What if o is 1 and RANDOM%30 returns 0? And on the next iteration, too?

@VadimR - I think the boundary conditions are fixed now.

If o is 28 initially, and RANDOM%29 returns 28, then first iteration prints 30 spaces if I'm not mistaken.

@VadimR - true - fixed (I think)

Smalltalk, 161 159 145-60 = 85
all columns are 30chars long (operating in mutable string b);
random movement chance is adjusted by biasing rnd value with p (rnd(0..29)-p), taking the sign (-1/0/1) and then adjusting to (-1/+1) via (-1|1), which is taken as move delta (effectively computes: x sign<=0 ifTrue:-1 ifFalse:1). As ST uses 1-based indexing, I have to adjust all string refs by +1 (plz appreciate the -1|1 bit fiddling hack ;-) ).
p:=((r:=Random)next*29)rounded.(b:=String new:30)at:p+1put:$..0to:29do:[:i|b at:p+1put:$ .p:=(p+(((r next*29)-p)sign-1|1))min:29max:0.b at:p+1put:$..b printCR]

stealing an idea from Ruby version (thanx&Up @fipgr), I can get rid of the min/max check:
p:=((r:=Random)next*29)rounded.(b:=String new:30)at:p+1put:$..1to:30 do:[:i|b at:p+1put:$ .p:=p+((r next-(p/29))sign-1|1).b at:p+1put:$.;printCR]

output: (I have manually added the col-numbers and vertical bars afterwards; the code above does not generate them)
 012345678901234567890123456789
|                     .        |
|                    .         |
|                   .          |
|                  .           |
|                 .            |
|                  .           |
|                 .            |
|                  .           |
|                 .            |
|                .             |
|                 .            |
|                .             |
|               .              |
|                .             |
|                 .            |
|                  .           |
|                 .            |
|                  .           |
|                 .            |
|                  .           |
|                 .            |
|                .             |
|               .              |
|                .             |
|               .              |
|                .             |
|               .              |
|              .               |
|               .              |
|              .               |
 012345678901234567890123456789

Ruby 69 66 64-60 = 4
i=rand(30);30.times{a=' '*30;a[i]=?.;puts a;i+=rand>i/29.0?1:-1}

Sample:
            .
           .
            .
           .
          .
           .
            .
             .
              .
             .
              .
               .
              .
               .
              .
             .
            .
             .
              .
             .
              .
             .
            .
             .
            .
             .
            .
           .
          .
           .

You can save a byte with i=rand 30; instead of i=rand(30);.

C, 86
Assuming that seeding the rand() function is not required.
k=30;main(i){i=rand()%k;while(k--){printf("%*c\n",i+=i==30?-1:i==1||rand()%2?1:-1,46);}}

Explanation:
In C, in "%*c" the * means that the length of the output will have a minimum length, and this minimum length is determined by the argument of the function call (in this case, it is i+=i==30?-1:i==1||rand()%2?1:-1. The c means the next argument (46) is a character (the dot).
As for the boundary check, I apologise that I forgot about that. I have now added this to the answer, at the cost of 15 chars. The ternary operator works as follows: boolean_condition?value_if_true:value_if_false. Note that in C true is 1 and false is 0.

Can you expand on what is going on in your code? I'm having trouble understanding how printf("%*c\n",i+=rand()%2?1:-1,46) prints the spaces, as well as how it keeps the dot from possibly moving past 29. Thanks in advance. (Sorry, I'm not a C programmer.)

@fireeyedboy done, hope you understand :)

Aaaah, I kind of had the feeling you were cheating a little bit there. ;-) But the rest is clear indeed now. Thank you! And nice solution! Does C also have the strange behavior with rand()%2 in that it is very predictable (odd/even turns)? I tried your rand()%2 in my PHP solution, and it exhibited this very predictable behavior (as opposed to rand(0,1). Since PHP makes a lot of use of C libraries (if I'm correct) I was wondering whether your C program has the same 'flaw'.

@fireeyedboy I did not seed the rand() function. In C if rand() is not seeded explicitly, it always uses the same seed every time. That's why it is predictable. If I had to seed it I can do srand(time()); which costs 14 chars

But is it so predictable that it switches from odd to even on each subsequent call as well? PHP claims rand() doesn't need to be seeded with srand() anymore, but still shows this odd behavior.

You can use srand(&k) to (probably) have a different random sequence each time the program runs.
@fireeyedboy - I don't see a reason why it would switch every call - see http://codepad.org/NLPA9FXP for an example. As far as srand(), I'm not familiar enough with PHP's implementation, but srand() is required to prevent predictable results from rand(). Without it, rand() may produce the same sequence of numbers every time the program runs.

@millinon Thanks for the feedback. I ran your C example, on codepad, without the srand(), and it doesn't appear to have the odd/even oddity. Must be due to PHP's own implementation. I guess they're not using the C library implementation for that one then. Or, perhaps it is a Windows specific oddity (as I presume codepad doesn't run on Windows).

@fireeyedboy Codepad uses GCC: http://codepad.org/about . I'm pretty sure that means it's using glibc, which contains the srand() implementation.

Java: 204 183 182 176 175 characters - 10 - 50 = 115
class K{public static void main(String[]y){int k,j=0,i=(int)(29*Math.random());for(;j++<30;i+=Math.random()*28<i?-1:1)for(k=0;k<31;k++)System.out.print(k>29?10:k==i?'.':32);}}

First, the dot position must be 0 < x < 30, i.e. [1-29]. This generates a number between 0 and 28 uniformly distributed, and for the purposes of this program [0-28] has the same effect as [1-29]:
i=(int)(29*Math.random());

I personally preferred if it would be normally distributed around 14, but my answer would be longer:
i=0;for(;j<29;j++)i+=(int)(2*Math.random());

Second, this code ensures that it tends to be in the middle:
i+=Math.random()*28<i?-1:1

The probability to get +1 is larger as smaller is the value of i, and we have the opposite for -1. If i is 0, the probability of getting +1 is 100% and the probability of getting -1 is 0%. If i is 28, the opposite to that will happen.
Third, by replacing the 32 at the end by '_' to see the output easier, we see that each line has 30 characters plus a new line:
__________.___________________
_________.____________________
________._____________________
_________.____________________
__________.___________________
___________.__________________
__________.___________________
_________.____________________
________._____________________
_________.____________________
________._____________________
_________.____________________
__________.___________________
_________.____________________
__________.___________________
___________.__________________
__________.___________________
_________.____________________
__________.___________________
___________.__________________
____________._________________
_____________.________________
____________._________________
_____________.________________
______________._______________
_____________.________________
______________._______________
_______________.______________
______________._______________
_____________.________________

Thanks to @VadimR (now, user2846289) for pointing out a misunderstanding in a prior version.
Thanks to @KevinCruijssen for shaving out 6 characters, even after more than two and a half years after this answer was initially posted.

But i getting to 0 is illegal, isn't it?

@VadimR, for me i is in the range [0-29]. This is equivalent to [1-30] or [288-317], the output would be the same. What matters is that there are 30 integer numbers in the interval [0-29].

"The number of spaces is the x position of your dot defined with 0 < x < 30" I.e. the number of spaces (or 0-based dot position) is 1..29. i can't be 0. I understand it's all about having fun but still it is sad.

@VadimR, Oh, thanks. Fixed. This means that the dot will never be in the rightmost posistion, but anyway, that is what was specified.

I'm sorry, but it didn't fix anything. Imagine i gets 1 initially, and on first iteration Math.random() is 0, then i gets 0. Please don't get me wrong, it's not about your answer. Rather about my inability to read most languages other than C-like. Then with no reaction (except for upvotes) about errors, how can I know they are right or not?

@VadimR For me it looks right. I am fixing the start of the interval at 0 (i.e., imagine that i == x-1, so 0 < x < 30 implies -1 < i < 29 and then 0 <= i <= 28). If this does not changes the output, it is valid. So, 1 is actually the second position in the interval. If Math.random() returns 0, then the dot will go to the first position. Don't see a problem here.

I know it's been more than 2.5 years, but you can golf it some more: class K{public static void main(String[]y){int k,j=0,i=(int)(29*Math.random());for(;j++<30;i+=Math.random()*28>=i?1:-1)for(k=0;k<31;k++)System.out.print(k>29?10:k==i?'.':32);}} (176 - 10 - 50 = 116 bytes) (j=0 at initialization; j++ directly at for-check; replace strings with chars and use their integer value for two out of the three of them)

@KevinCruijssen Well spotted. Thank you.

PHP, 118 113 112 111 (, -10 bonus points = 101)
(second try, with horribly predictable rand() behavior, and a little more efficiency)
for($n=30,$i=rand(1,29),$t=$s=pack("A$n",'');$n--;$i+=$i<2|rand()%2&$i<28?1:-1,$t=$s){$t[$i-1]='.';echo"$t\n";}

Possible result:
______._______________________
_____.________________________
______._______________________
_____.________________________
______._______________________
_____.________________________
______._______________________
_____.________________________
______._______________________
_____.________________________
______._______________________
_____.________________________
______._______________________
_____.________________________
______._______________________
_____.________________________
______._______________________
_____.________________________
______._______________________
_____.________________________
______._______________________
_____.________________________
______._______________________
_____.________________________
______._______________________
_____.________________________
______._______________________
_____.________________________
______._______________________
_____.________________________

PHP, 130 (, -10 bonus points = 120)
(first try)
This could probably still be much more efficient:
for($n=30,$i=rand(1,29),$t=$s=str_repeat(' ',$n)."\n";$n--;$i=$i<2?2:($i>28?28:(rand(0,1)?$i+1:$i-1)),$t=$s){$t[$i-1]='.';echo$t;}

If I replace the space with an underscore (for display purposes), this is a possible result:
________._____________________
_______.______________________
______._______________________
_______.______________________
________._____________________
_______.______________________
______._______________________
_______.______________________
______._______________________
_______.______________________
________._____________________
_______.______________________
________._____________________
_________.____________________
__________.___________________
___________.__________________
__________.___________________
___________.__________________
__________.___________________
_________.____________________
________._____________________
_________.____________________
________._____________________
_______.______________________
______._______________________
_____.________________________
____._________________________
_____.________________________
____._________________________
___.__________________________

Oddly enough, if I replace rand(0,1) with rand()%2 (PHP 5.4, on Windows XP), the random result always switches from odd to even, and vice versa, on each next iteration, making rand() worryingly predictable, in that sense, all of a sudden. This 'bug' appears to be one that has been known since 2004. Not entirely sure whether it's exactly the same 'bug' though.

Mathematica 157-10-50 = 97
A random number from 1-30 is used for starting.
All the remaining column numbers from the dot are chosen via
RandomChoice[If[c > 15, {2, 1}, {1, 2}] -> {-1, 1}] + c, which translates to:
"If the prior column number was greater than 15, select one number from the set {-1,1}, with -1 weighted 2:1 with respect to 1; otherwise, flip the weights and choose from the same set.
ReplacePart replaces the element in a list of 30 blank spaces that corresponds to the column of interest.
f@c_ := Switch[d = RandomChoice[If[c > 15, {2, 1}, {1, 2}] -> {-1, 1}] + c, 1, 2, 30, 29, d, d]
Row@ReplacePart[Array["_" &, 29], # -> "."] & /@ NestList[f, RandomInteger@29+1, 30] // TableForm

Nice use of RandomChoice[]

><>, 358 - 10 = 348
This won't win at codegolf, but it works. (On windows 7 with this interpreter, which implements the "p" instruction differently than the esolang page defines it)
1v        >a"                              "v
v<      0<} vooooooooooooooooooooooooooooooo<
&  _>   v : >$" "@p1+:2f*(?v;
  |x1>  v^}!               <
  |xx2> v p
  |xxx3>v
  |xxxx4v $
>!|xxx< v }
  |xxxx6v }
  |xxx7>v @
  |xx8> v :
  |x9v  < @>  5)?v$:67*)?vv
   _>>&?v!@^     >$:b(?v v
  v }"."< :        v+ 1<  <
  >a+b+00}^0}}${"."< <- 1<

The name of this language can't be googled, so here's its esolang article for the curious.

Can you code the requirement for the -50 in less than 50 characters?

@Victor Probably, but ><> is a giant pain to code in (a fun giant pain), so I need to take a break from it.

@SirCxyrtyx this made me chuckle. Well golfed sir.

Python 2.7: 126 109 -10-50 = 49
Got rid of the hard-coded starting point - now starts at random point. Because of this, I needed randint, so I decided to use that instead of choice for the offset. Used the (-1)**bool trick for that.
from random import randint as r;p=r(0,29)
for i in range(30):
 print' '*p+'.'+' '*(29-p);p+=(-1)**(r(0,29)<p)

Some great answers here. First attempt in Python, thinking about improvements. Not helped by the need for an import.
-10 - yes 30 chars + \n on each line
-50 - the further away from the centre, the more likely a move the other way (accomplished by building a list with a different number of +/i offsets)
Previous attempt:
from random import choice;p,l=15,[]
for i in range(30):
 q=29-p;l+=[' '*p+'.'+' '*q];p+=choice([1]*q+[-1]*p)
print'\n'.join(l)

Your for loop can all be on one line, but even better is for i in[0]*30: and better still is eval"..."*30.

J 42 characters - 50 -10 = -18
'_.'{~(|.~((I.%<:@#)*@-?@0:))^:(<@#)1=?~30

Explanation, starting from the right (some knowledge about trains comes in handy):
init=: 0=?~30          NB. where is the 0 in the random permutation of [0,29]
rep =: ^:(<@#)         NB. repeat as many times as the array is long, showing each step

rnd =: ?@0:            NB. discards input, generates a random number between 0 and 1

signdiff =: *@-        NB. sign of the difference (because this works nicely with
                       NB. the shift later on).

left_prob =: (I.%<:@#) NB. probability of shifting left. The position of the one (I.) divided by the length -1.

shift =: |.~           NB. x shift y , shifts x by y positions to the left.

output =: {&'_.'       NB. for selecting the dots and bars.

NB. Piecing things together:
output (shift (left_prob signdiff rnd))rep init

Center tendency, -50, example over 1000 runs:
NB. Amounts of ones in each column (sum)
   ]a=:+/ (|.~((I.%<:@#)*@-?@0:))^:(<1000)0=?30
0 0 0 0 0 0 2 6 10 12 25 60 95 121 145 161 148 99 49 27 19 13 6 1 1 0 0 0 0 0
   +/a NB. check the number of ones in total
1000
   |. |:(<.a%10) #"0 1] '*' NB. plot of those values
           *
           *
          ***
          ***
         ****
         ****
         ****
        ******
        ******
        ******
       *******
       *******
       ********
       ********
      **********
    **************

Example run, outputting exactly 30 bytes each line
_______________.______________
________________._____________
_______________.______________
________________._____________
_______________.______________
________________._____________
_______________.______________
________________._____________
_______________.______________
________________._____________
_______________.______________
______________._______________
_______________.______________
________________._____________
_________________.____________
________________._____________
_______________.______________
______________._______________
_____________.________________
____________._________________
___________.__________________
__________.___________________
___________.__________________
__________.___________________
___________.__________________
__________.___________________
___________.__________________
____________._________________
_____________.________________
______________._______________

A very good solution!

A very good challenge too!

Java - 198 183 characters
This is just a plain, simple, direct and uncreative golf of the example that you had given in the question.
class A{public static void main(String[]y){int c,j,i=(int)(Math.random()*30);for(c=30;c>0;c--)for(j=i+=i<2?1:i>28?-1:Math.random()>0.5?1:-1;j>=0;j--)System.out.print(j>0?" ":".\n");}}

D - 167, 162, 144 ( 154 - 10 )
Golfed:
import std.stdio,std.random;void main(){int i=uniform(1,30),j,k;for(;k<30;++k){char[30]c;c[i]='.';c.writeln;j=uniform(0,2);i+=i==29?-1:i==0?1:j==1?1:-1;}}

Un-golfed:
import std.stdio, std.random;

void main()
{
    int i = uniform( 1, 30 ), j, k;

    for(; k < 30; ++k )
    {
        char[30] c;
        c[i] = '.';
        c.writeln;
        j = uniform( 0, 2 );
        i += i == 29 ? -1 : i == 0 ? 1 : j == 1 ? 1 : -1;
    }
}

EDIT 1 - I'm not quite sure if my code qualifies for the -50 bonus or not. i doesn't always start in the middle, but during the for loop, the dot never moves more than like 3 places either direction, so when i does start near the middle, the whole thing tends to stay there as well.
EDIT 2 - Code now qualifies for the -10 bonus, as it prints an array of 29 characters followed by LF for a total of exactly 30 chars per line.

as it prints an array of 29 characters followed by LF - It should be 30 characters followed by a LF.

@Victor ahh, thank you for the correction, I misinterpreted the main post.

Javascript 125 73 72 60 (120 - 50 - 10)
i=0;r=Math.random;s=r()*30|0;do{a=Array(30);a[s=s>28?28:s?r()<s/30?s-1:s+1:1]='.';console.log(a.join(' '))}while(++i<30)

EDIT: Fix for 50 point bonus and 10 point bonus.
EDIT 2: Even shorter!

can you explain, where you get the 50 points bonus? I am not getting it at the moment...

@Kostronor I just saw the edit for the requirement. Looks like I don't get the 50 points yet.

@acbabis, well done ! You can save some bytes (116) : r=Math.random;s=r()*30|0;for(i=0;i++<30;a=Array(30)){a[s=s>28?28:s?r()<s/30?s-1:s+1:1]='.';console.log(a.join(' '))}

@Michael Thanks for the tips. Couldn't get the array init inside the for working, though; had to use a do while.

Batch - (288 Bytes - 10) 278
@echo off&setlocal enabledelayedexpansion&set/ap=%random%*30/32768+1&for /l %%b in (1,1,30)do (set/ar=!random!%%2&if !r!==1 (if !p! GTR 1 (set/ap-=1)else set/ap+=1)else if !p! LSS 30 (set/ap+=1)else set/ap-=1
for /l %%c in (1,1,30)do if %%c==!p! (set/p"=."<nul)else set/p"=_"<nul
echo.)

Un-golfed:
@echo off
setlocal enabledelayedexpansion
set /a p=%random%*30/32768+1
for /l %%b in (1,1,30) do (
    set /a r=!random!%%2
    if !r!==1 (
        if !p! GTR 1 (set /a p-=1) else set /a p+=1
    ) else if !p! LSS 30 (set /a p+=1) else set /a p-=1
    for /l %%c in (1,1,30) do if %%c==!p! (set /p "=."<nul) else set /p "=_"<nul
    echo.
)

To output spaces instead of underscores - 372 Bytes -
@echo off&setlocal enabledelayedexpansion&for /f %%A in ('"prompt $H &echo on&for %%B in (1)do rem"')do set B=%%A
set/ap=%random%*30/32768+1&for /l %%b in (1,1,30)do (set/ar=!random!*2/32768+1&if !r!==1 (if !p! GTR 1 (set/ap-=1)else set/ap+=1)else if !p! LSS 30 (set/ap+=1)else set/ap-=1
for /l %%c in (1,1,30)do if %%c==!p! (set/p"=."<nul)else set/p"=.%B% "<nul
echo.)

Looking for some help with the following logic, surely this isn't the most space efficient method (!r! will expand to either 1 or 2) -
if !r!==1 (
    if !p! GTR 1 (set /a p-=1) else set /a p+=1
) else if !p! LSS 30 (set /a p+=1) else set /a p-=1

It golfs down to: if !r!==1 (if !p! GTR 1 (set/ap-=1)else set/ap+=1)else if !r! LSS 30 (set/ap+=1)else set/ap-=1

R, 107 characters - 60 points bonus=47
s=sample;i=s(29,1);for(j in 1:30){a=rep(' ',30);i=i+s(c(-1,1),1,p=c(i-1,29-i));a[i]='.';cat(a,'\n',sep='')}

i is the index of the dot. a is the array of 30 spaces. Starting point is random (uniformly from 1 to 29). At each iteration we randomly add -1 or +1 to i with weighted probabilities: i-1 for -1 and 29-i  for +1 (values fed as probabilities don't need to sum to one), meaning that it tends to orient the dot towards the center while preventing it from below 1 or above 29 (since their probability fall to 0 in both case).
Example run with _ instead of spaces for legibility:
> s=sample;i=s(1:30,1);for(j in 1:30){a=rep('_',30);i=i+s(c(-1,1),1,p=c(i-1,29-i));a[i]='.';cat(a,'\n',sep='')}
_______________________.______
______________________._______
_____________________.________
______________________._______
_____________________.________
______________________._______
_____________________.________
______________________._______
_____________________.________
____________________._________
_____________________.________
______________________._______
_____________________.________
______________________._______
_____________________.________
____________________._________
___________________.__________
____________________._________
___________________.__________
__________________.___________
_________________.____________
________________._____________
_______________.______________
______________._______________
_______________.______________
________________._____________
_________________.____________
________________._____________
_______________.______________
______________._______________

If I'm not mistaken reading your code, i can become either 0 or 30, no?

Yes you're right it can be 30 (not more though), i ll change that.

It's fixed now. The probability to go from 1 to 0 or to go from 29 to 30 is now 0. The random starting point is now between 1 and 29.

Hint: You can save 2 more characters by replacing s(1:29,1) with s(29,1).

@SvenHohenstein you're right I always forget about that one

C# 184 - 10 - 50 = 123
using System;namespace d{class P{static void Main(){var r=new Random();int p=r.Next(30);for(int i=0;i<30;i++){Console.WriteLine(".".PadLeft(p+1).PadRight(29));p+=r.Next(30)<p?-1:1;}}}}

Output
space replaced with _ for legibility.
____________.________________
___________._________________
__________.__________________
___________._________________
____________.________________
_____________._______________
______________.______________
_____________._______________
______________.______________
_______________._____________
______________.______________
_______________._____________
______________.______________
_______________._____________
______________.______________
_____________._______________
____________.________________
___________._________________
____________.________________
_____________._______________
______________.______________
_____________._______________
____________.________________
___________._________________
____________.________________
___________._________________
____________.________________
___________._________________
__________.__________________
___________._________________

I am pretty sure that it should be possible to get a smaller code in the if...else if...else at the end of you code. Further, your output makes me get some doubt that it tends to be in the middle, but your code seems to be right.

Forgot to update the output when i edited the code. The r.Next(30)<p?-1:1; makes it happen. Not sure you can go smaller with the if statements. switch is big because of the mandatory break / return and the final else requires a default:{} case and that is also long.

@Victor thanks for the input. i made some edits.

If p is zero, the p+=r.Next(30)<p?-1:1; will always get 1, so no need for the if(p==0). Ditto for p==29. p will never be 30, so you can get rid of the else if.

@Victor grand. ill make those changes. Ta.

J, 42 characters, no bonuses
' .'{~(i.30)=/~29<.0>.+/\(-0&=)?(,2#~<:)30

Example run:
          ' .'{~(i.30)=/~29<.0>.+/\(-0&=)?(,2#~<:)30
                       .
                      .
                     .
                      .
                     .
                      .
                     .
                      .
                       .
                      .
                     .
                    .
                     .
                    .
                     .
                    .
                     .
                      .
                       .
                        .
                       .
                        .
                       .
                      .
                     .
                      .
                       .
                      .
                     .
                    .

Python 2.7 (126 - 10 (fix length) - 50 (Center Tendency) = 66)
The following program have a center tendency over a larger sample
s=id(9)%30
for e in ([[0,2][s>15]]*abs(s-15)+map(lambda e:ord(e)%2*2,os.urandom(30)))[:30]:
    s+=1-e;print" "*s+"."+" "*(28-s)

Demo
         .
        .
       .
      .
     .
      .
       .
        .
         .
          .
           .
          .
           .
          .
         .
        .
       .
        .
       .
      .
     .
      .
       .
      .
     .
    .
   .
    .
   .
    .

Like the s=id(9)%30 for the seeding. os needs importing, though? And does this cover the full 1-30 range? Oh wait...rereads the inequality at top of page

PowerShell, 77 - 10 - 50 = 17
$x=random 30
1..30|%{$x+=random(@(-1)*$x+@(1)*(29-$x))
'_'*$x+'.'+'_'*(29-$x)}

Output
_.____________________________
__.___________________________
___.__________________________
____._________________________
___.__________________________
____._________________________
_____.________________________
______._______________________
_______.______________________
______._______________________
_____.________________________
______._______________________
_______.______________________
________._____________________
_________.____________________
__________.___________________
___________.__________________
__________.___________________
___________.__________________
____________._________________
___________.__________________
__________.___________________
_________.____________________
__________.___________________
_________.____________________
________._____________________
_________.____________________
________._____________________
_________.____________________
__________.___________________

Smart random. You could to use a golfed version $x=random 30;1..30|%{' '*($x+=,-1*$x+,1*(29-$x)|random)+'.'|% *ht 30}. 66 bytes - 10 - 50 = 6 score points

JavaScript ES6 125 - 10 (30 character lines) - 50 (shifts toward middle) = 65
I had an epiphany going up the lift to my unit, so I had to get it down before it left my memory...
z=(j=Array(t=29).join`_`)+"."+j;x=(r=Math.random)()*t;for(i=30;i--;)console.log(z.substr(x=(x+=r()<x/t?-1:1)>t?t:x<0?0:x,30))

A little variable positional shuffling and a little creativity for calculating the shift probability indicated by x/t... (Thanks Kostronor for pointing it out!) I now gain the -50 bonus for shift to the middle, and I also made the starting position within the full range of the line, which allowed me to shave two bytes!
....5....0....5....0....5....0 <-- Ruler
_.____________________________
__.___________________________
___.__________________________
__.___________________________
___.__________________________
__.___________________________
_.____________________________
__.___________________________
___.__________________________
__.___________________________
___.__________________________
____._________________________
_____.________________________
______._______________________
_______.______________________
________._____________________
_______.______________________
______._______________________
_______.______________________
________._____________________
_______.______________________
________._____________________
_________.____________________
__________.___________________
_________.____________________
__________.___________________
___________.__________________
____________._________________
_____________.________________
______________._______________

Isn't it that randomness of initial dot position here is limited to 2 or 3 possibilities? And that's what keeping dot in the middle (because of very short number of runs = 30) and therefore worth -50?

Quoting the OP's text: "Your program starts with a random x position and every turn shifts this position randomly by 1 to the left or right" My code initially is defined at 15+r()*2 which could be anything from 15 to 16.9999999998 or so which could round off to 17. the additional x+=r()<.5?-1:1 throws a little more randomness by bringing it to a range of 14 to 18, so technically a random number which is within the definition of what was asked... By bending that rule, the flip (+1,-1) will in most cases bring it back toward the middle... ;)

Well, on the random thing, you got me... It was meant to be 'a random position from all possible positions' but it gives you not much advantage, as the 50 points clearly not apply! Please reread the explanation on this bonus, a fixed 0,5 percent do not get it!

Valid point, I'll redo my score accordingly...

@Kostonor Code updated with proper solution, updated score accordingly!

Javascript, 125 (135 - 10)
q=Math.random,p=~~(q()*31)+1;for(i=0;i++<30;){s='',d=j=1;for(;j++<31;)s+=j==p?'.':" ";p+=q()<.5?1:-1;p-=p>28?2:p<2?-2:0;console.log(s)}

Comments and advice is welcome.

Sadly, your solution does not qualify, compare your output with the output of other solutions. Shift the dot by one character.

@Kostronor Oh! oh! I am so sorry! I forgot to read that part of the question! I will try to develop a new version soon. Thanks for pointing out!

@Kostronor Program edited.

k, 53 - 10 - 50 = -7
Solution 1
{{a:30#" ";a[x]:".";a}'{x+$[*x<1?!30;1;-1]}\[x;*1?x]}

Usage
{{a:30#" ";a[x]:".";a}'{x+$[*x<1?!30;1;-1]}\[x;*1?x]}30

"      .                       "
"       .                      "
"      .                       "
"       .                      "
"      .                       "
"       .                      "
"        .                     "
"         .                    "
"        .                     "
"         .                    "
"        .                     "
"         .                    "
"          .                   "
"           .                  "
"            .                 "
"             .                "
"              .               "
"               .              "
"              .               "
"             .                "
"            .                 "
"           .                  "
"          .                   "
"         .                    "
"        .                     "
"       .                      "
"        .                     "
"         .                    "
"          .                   "
"         .                    "
"          .                   "

Solution 2
{r::x;{a:r#" ";a[x]:".";a}'{a:r#0b;a[x?r]:1b;x+$[a@*1?r;-1;1]}\[x;*1?x]}[30]

PHP
With the centring bonus: 82 - 50 = 32
$i=rand(0,29);for($c=0;$c++<30;rand(0,28)<$i?$i--:$i++)echo pack("A$i",'').".\n";

For this version (old versions below), removed the min/max checking as that's taken care of in the centring code. rand(1,28) becomes important here as it allows for the $i++ to push itself up to 29 (actual max).
edit: unnecessary parenthesis, moved shifting code

Simple algorithm for centring: generates a new number between 0 and 29 and compares it to the current one. Takes advantage of the "probability" of getting a number on the bigger side to draw towards the centre.
Actual result: (line numbering added afterwards)
01|        .
02|       .
03|        .
04|         .
05|          .
06|           .
07|            .
08|           .
09|            .
10|             .
11|              .
12|             .
13|            .
14|             .
15|            .
16|             .
17|            .
18|             .
19|              .
20|               .
21|              .
22|             .
23|              .
24|               .
25|                .
26|               .
27|                .
28|                 .
29|                .
30|               .

Archived:
$i=rand(0,29);for($c=0;$c++<30;){($i<1?$j=1:($i>28?$j=28:$j=rand(0,29)));($j<$i?$i--:$i++);echo pack("A$i",'').".\n";} 119 characters
$i=rand(0,29);for($c=0;$c++<30;){($i<1?$i++:($i>28?$i--:(rand(0,29)<$i?$i--:$i++)));echo pack("A$i",'').".\n";} 112 characters

I'm a little impressed that I shaved off 49 characters since my first version...

shaved 44 characters now. Which must mean it was 39 last time.

JavaScript
114 chars - 10 (30 char lines) - 50 (pull dot towards the middle) = 54
for(f=Math.random,a=[],i=30,j=k=f()*i|0;i--;a[j]='.',a[j+=29-k]='\n',j+=k+=f()>k/29?1:-1);console.log(a.join('-'))

However, I noticed that a 10 character reward for filling up the lines to 30 chars may be a bad deal; so:
102 chars - 50 (pull dot towards the middle) = 52
for(f=Math.random,a=[],i=30,j=k=f()*i|0;i;i--,a[j]='.\n',j+=k+=f()>k/29?1:-1);console.log(a.join('-'))

Kudos to @WallyWest for the simplified pull direction conditional f()>k/29?1:-1, my first draft used two nested conditionals.

Racket 227 bytes (-10 for 30 characters, -50 for shift to midline = 167)
At each step, dot is twice more likely to move towards midline than away from it:
(let lp((r(random 1 31))(c 0)(g(λ(n)(make-string n #\space))))(set! r
(cond[(< r 1)1][(> r 30)30][else r]))(printf"~a~a~a~n"(g r)"*"(g(- 29 r)))
(when(< c 30)(lp(+ r(first(shuffle(if(> r 15)'(-1 -1 1)'(1 1 -1)))))(add1 c)g)))

Ungolfed:
(define (f)
    (let loop ((r (random 1 31))
               (c 0)
               (g (λ (n) (make-string n #\space))))
      (set! r (cond
                [(< r 1) 1]
                [(> r 30) 30]
                [else r] ))
      (printf "~a~a~a~n" (g r) "*" (g (- 29 r)))
      (when (< c 30)
        (loop (+ r
                 (first
                  (shuffle
                   (if (> r 15)
                       '(-1 -1 1)
                       '(1 1 -1)))))
              (add1 c)
              g))))

Testing:
(println "012345678901234567890123456789")
(f)

Output:
"012345678901234567890123456789"
                       *
                      *
                       *
                        *
                         *
                        *
                       *
                      *
                     *
                      *
                     *
                    *
                     *
                      *
                     *
                    *
                   *
                  *
                 *
                *
               *
                *
                 *
                *
                 *
                *
                 *
                *
                 *
                *
               *

Nice solution! Racket is really interesting. You can give yourself the 50 bonus points and check if you apply for the extra 10 :-)

Scala, 95 - 10 = 85 bytes
def r=math.random
Seq.iterate(r*30,30){n=>println(("#"*30)updated(n.toInt,'.'))
(r*2-1+n)round}

I'm still thinking about the 50 byte bonus.
Explanation:
def r=math.random //define a shortcut for math.random, which returns a number 0 <= n < 1
Seq.iterate(      //build a sequence,
  r*30,             //starting with a random number bewteen 0 and 29
  30                //and containing 30 elements.
){n=>             //Calculate each element by applying this function to the previous element
  println(        //print...
    (" "*30)             //30 spaces
    updated(n.toInt,'.') //with the n-th char replaced with a dot
  )               //and a newline.
                  //The next element is
  (r*2-1+n)       //an random number between -1 and 1 plus n
  round           //rounded to the nearest integer.
}


text:
Reflective evolutionary algorithm
You have to write a program, implementing a function digitsum(int i). The program has to modify its own code (for languages, where this is not possible with f.e. reflection, please be creative) to get itself to solve the goal.
You start with
function digitsum(int i){
    return i;
}

and implement an evolutionary algorithm that will modify the above function until it returns valid digitsums on function call.
As this is a popularity contest, you have very much free hands, please be creative!
Guidelines:

Start with the defined function (translated to your language of course).
Print out at least the fittest function of each generation.
Print out your working solution tested for 0 < i < 10000.
Be creative!

Do not:

Hint your program to the solution, please use your whole language options!
Throw errors to the console.
Use any external input. You can write and save to files created by your program. No internet.

The valid solution with the most upvotes wins!

Does no libraries allowed mean no libc?

i have removed the no libraries as it would be to complex imo, so the voters can decide if there are to many libraries used!

+1 Hard interesting question. Will need some hours to produce an answer. Unfortunately don't expect to get more than say 2 or 3 answers.

wonders What is the difference between this and a recursive function? I can't quite figure it out, as in I can't visualize the scenario feels retarded xD

"please use your whole language options!" seems to be an explicit request to risk the program deleting important files.

@Peter Taylor you would then have to sanitize your program to prevent this risk. This term means that your program should mind using arrays, lists and loops, executing file access would be to much... I will rework the challenge so that the problem is more understandable in scope and restrictions!

It is required that the language where the digitsums function is expressed to be the same as the language where the genetic algorithm is expressed? It looks that yes, but I just want to be sure of that (or be sure that it is not).

C#
Almost entirely random and raw assembly solution. As far as C# and pretty much any other platform goes, this is as low level as possible. Luckily, C# allows you to define methods during runtime in IL (IL is intermediate language, the byte-code of .NET, similar to assembly). The only limitation of this code is that I chose some opcodes (out of hundreds) with an arbitrary distribution which would be necessary for the perfect solution. If we allow all opcodes, chances of a working program are slim to none, so this is necessary (as you can imagine, there are many many ways that random assembly instructions can crash, but luckily, they don't bring down the whole program in .NET). Other than the range of possible opcodes, it's completely random slicing and dicing IL opcodes without any kind of hinting. I am pretty surprised but this actually seems to work, some generated programs do not crash and do produce results!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection.Emit;
using System.Diagnostics;
using System.Threading;

namespace codegolf
{
    class Program
    {
        // decompile this into IL to find out the opcodes needed for the perfect algo
        static int digitsumbest(int i)
        {
            var ret = 0;
            while (i > 0)
            {
                ret += i % 10;
                i /= 10;
            }
            return ret;
        }

        delegate int digitsumdelegate(int num);

        static Thread bgthread;

        // actually runs the generated code for one index
        // it is invoked in a background thread, which we save so that it can be aborted in case of an infinite loop
        static int run(digitsumdelegate del, int num)
        {
            bgthread = Thread.CurrentThread;
            try
            {
                return del(num);
            }
            catch (ThreadAbortException)
            {
                bgthread = null;
                throw;
            }
        }

        // evaluates a generated code for some inputs and calculates an error level
        // also supports a full run with logging
        static long evaluate(digitsumdelegate del, TextWriter sw)
        {
            var error = 0L;

            List<int> numbers;
            if (sw == null) // quick evaluation
                numbers = Enumerable.Range(1, 30).Concat(Enumerable.Range(1, 70).Select(x => 5000 + x * 31)).ToList();
            else // full run
                numbers = Enumerable.Range(1, 9999).ToList();

            foreach (var num in numbers)
            {
                try
                {
                    Func<digitsumdelegate, int, int> f = run;
                    bgthread = null;
                    var iar = f.BeginInvoke(del, num, null, null);
                    if (!iar.AsyncWaitHandle.WaitOne(10))
                    {
                        bgthread.Abort();
                        while (bgthread != null) ;
                        throw new Exception("timeout");
                    }
                    var result = f.EndInvoke(iar);
                    if (sw != null)
                        sw.WriteLine("{0};{1};{2};", num, digitsumbest(num), result);
                    var diff = result == 0 ? 15 : (result - digitsumbest(num));
                    if (diff > 50 || diff < -50)
                        diff = 50;
                    error += diff * diff;
                }
                catch (InvalidProgramException)
                {
                    // invalid IL code, happens a lot, so let's make a shortcut
                    if (sw != null)
                        sw.WriteLine("invalid program");
                    return numbers.Count * (50 * 50) + 1;
                }
                catch (Exception ex)
                {
                    if (sw != null)
                        sw.WriteLine("{0};{1};;{2}", num, digitsumbest(num), ex.Message);
                    error += 50 * 50;
                }
            }
            return error;
        }

        // generates code from the given byte array
        static digitsumdelegate emit(byte[] ops)
        {
            var dm = new DynamicMethod("w", typeof(int), new[] { typeof(int) });
            var ilg = dm.GetILGenerator();
            var loc = ilg.DeclareLocal(typeof(int));

            // to support jumping anywhere, we will assign a label to every single opcode
            var labels = Enumerable.Range(0, ops.Length).Select(x => ilg.DefineLabel()).ToArray();

            for (var i = 0; i < ops.Length; i++)
            {
                ilg.MarkLabel(labels[i]);

                // 3 types of jumps with 23 distribution each, 11 types of other opcodes with 17 distribution each = all 256 possibilities
                // the opcodes were chosen based on the hand-coded working solution
                var c = ops[i];
                if (c < 23)
                    ilg.Emit(OpCodes.Br_S, labels[(i + 1 + c) % labels.Length]);
                else if (c < 46)
                    ilg.Emit(OpCodes.Bgt_S, labels[(i + 1 + c - 23) % labels.Length]);
                else if (c < 69)
                    ilg.Emit(OpCodes.Bge_S, labels[(i + 1 + c - 46) % labels.Length]);
                else if (c < 86)
                    ilg.Emit(OpCodes.Ldc_I4, c - 70); // stack: +1
                else if (c < 103)
                    ilg.Emit(OpCodes.Dup); // stack: +1
                else if (c < 120)
                    ilg.Emit(OpCodes.Ldarg_0); // stack: +1
                else if (c < 137)
                    ilg.Emit(OpCodes.Starg_S, 0); // stack: -1
                else if (c < 154)
                    ilg.Emit(OpCodes.Ldloc, loc); // stack: +1
                else if (c < 171)
                    ilg.Emit(OpCodes.Stloc, loc); // stack: -1
                else if (c < 188)
                    ilg.Emit(OpCodes.Mul); // stack: -1
                else if (c < 205)
                    ilg.Emit(OpCodes.Div); // stack: -1
                else if (c < 222)
                    ilg.Emit(OpCodes.Rem); // stack: -1
                else if (c < 239)
                    ilg.Emit(OpCodes.Add); // stack: -1
                else
                    ilg.Emit(OpCodes.Sub); // stack: -1
            }

            ilg.Emit(OpCodes.Ret);
            return (digitsumdelegate)dm.CreateDelegate(typeof(digitsumdelegate));
        }

        static void Main(string[] args)
        {
            System.Diagnostics.Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle;

            var rnd = new Random();

            // the first list is just 10 small random ones
            var best = new List<byte[]>();
            for (var i = 0; i < 10; i++)
            {
                var initial = new byte[5];
                for (var j = 0; j < initial.Length; j++)
                    initial[j] = (byte)rnd.Next(256);
                best.Add(initial);
            }

            // load the best result from the previous run, if it exists
            if (File.Exists("best.txt"))
                best[0] = File.ReadAllLines("best.txt").Select(x => byte.Parse(x)).ToArray();

            var stop = false;

            // handle nice stopping with ctrl-c
            Console.CancelKeyPress += (s, e) =>
            {
                stop = true;
                e.Cancel = true;
            };

            while (!stop)
            {
                var candidates = new List<byte[]>();

                // leave the 10 best arrays, plus generate 9 consecutive mutations for each of them = 100 candidates
                for (var i = 0; i < 10; i++)
                {
                    var s = best[i];
                    candidates.Add(s);
                    for (var j = 0; j < 9; j++)
                    {
                        // the optimal solution is about 20 opcodes, we keep the program length between 15 and 40
                        switch (rnd.Next(s.Length >= 40 ? 2 : 0, s.Length <= 15 ? 3 : 5))
                        {
                            case 0: // insert
                            case 1:
                                var c = new byte[s.Length + 1];
                                var idx = rnd.Next(0, s.Length);
                                Array.Copy(s, 0, c, 0, idx);
                                c[idx] = (byte)rnd.Next(256);
                                Array.Copy(s, idx, c, idx + 1, s.Length - idx);
                                candidates.Add(c);
                                s = c;
                                break;
                            case 2: // change
                                c = (byte[])s.Clone();
                                idx = rnd.Next(0, s.Length);
                                c[idx] = (byte)rnd.Next(256);
                                candidates.Add(c);
                                s = c;
                                break;
                            case 3: // remove
                            case 4: // remove
                                c = new byte[s.Length - 1];
                                idx = rnd.Next(0, s.Length);
                                Array.Copy(s, 0, c, 0, idx);
                                Array.Copy(s, idx + 1, c, idx, s.Length - idx - 1);
                                candidates.Add(c);
                                s = c;
                                break;
                        }
                    }
                }

                // score the candidates and select the best 10
                var scores = Enumerable.Range(0, 100).ToDictionary(i => i, i => evaluate(emit(candidates[i]), null));
                var bestidxes = scores.OrderBy(x => x.Value).Take(10).Select(x => x.Key).ToList();
                Console.WriteLine("best score so far: {0}", scores[bestidxes[0]]);
                best = bestidxes.Select(i => candidates[i]).ToList();
            }

            // output the code of the best solution
            using (var sw = new StreamWriter("best.txt"))
            {
                foreach (var b in best[0])
                    sw.WriteLine(b);
            }

            // create a CSV file with the best solution
            using (var sw = new StreamWriter("best.csv"))
            {
                sw.WriteLine("index;actual;generated;error");
                evaluate(emit(best[0]), sw);
            }
        }
    }
}

Sorry I have no results so far because even with testing for 1..99 (instead of 1..9999) is pretty slow and I am too tired. Will get back to you tomorrow.
EDIT: I finished the program and tweaked it a lot. Now, if you press CTRL-C, it will finish the current run and output the results in files. Currently, the only viable solutions it produces are programs which always return a constant number. I'm starting to think that the chances of a more advanced working program are astronomically small. Anyway I will keep it running for some time.
EDIT: I keep tweaking the algorithm, it's a perfect toy for a geek like me. I once saw a generated program which actually did some random math and didn't always return a constant number. It would be awesome to run it on a few million CPU's at once :). Will keep running it.
EDIT: Here's the result of some completely random math. It jumps around and stays at 17 for the rest of the indices. It won't become conscious anytime soon.

EDIT: It's getting more complicated. Of course, as you would expect, it looks nothing like the proper digitsum algorithm, but it's trying hard. Look, a computer generated assembly program!

Looks very cool! I will look at your code tomorrow!

I actually tried a similar approach, and am also fighting hard with a good evaluation function. I also get stuck in local maxima (stuck in solutions, which return correct for 1..19, using fancy modulu operations). Up for you anyway!
PS: in order to get out of a local maximum, I'll try to introduce radical mutations occasionally, and let them develop (in a separate universe, maybe) for a while to be not immediately shot down by the others... (kind of like south america drifting from africa and developing different species ;-)

C#
This might not be completeley what you envisioned, but this is the best I could do right now. (At least with C# and CodeDom).
So how it works:

It calculates the digitsum base 2 (the base wasn't specified in the statement)
It tries to generate an expression with a lot of terms that look like ((i & v1) >> v2). These terms will be the genes that will be mutated through the run.
The fitness function simply compares the values with a pre-calculated array, and uses the sum of the absolute value of the differences. This means a 0 value means we have arrived to the solution, and the less the value the fitter the solution.

The code:
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using Microsoft.CSharp;
using System.IO;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;

namespace Evol
{
    class MainClass
    {
        const int BASE = 2;
        static int[] correctValues;
        static List<Evolution> values = new List<Evolution>();

        public static CodeCompileUnit generateCompileUnit(CodeStatementCollection statements) {
            CodeCompileUnit compileUnit = new CodeCompileUnit();
            CodeNamespace samples = new CodeNamespace("CodeGolf");
            compileUnit.Namespaces.Add(samples);
            samples.Imports.Add(new CodeNamespaceImport("System"));
            CodeTypeDeclaration digitSumClass = new CodeTypeDeclaration("DigitSum");
            samples.Types.Add(digitSumClass);
            CodeMemberMethod method = new CodeMemberMethod();
            method.Name = "digitsum";
            method.Attributes = MemberAttributes.Public | MemberAttributes.Static;
            method.ReturnType = new CodeTypeReference (typeof(int));
            method.Parameters.Add (new CodeParameterDeclarationExpression (typeof(int), "i"));
            method.Statements.AddRange (statements);
            digitSumClass.Members.Add(method);
            return compileUnit;
        }

        public static long CompileAndInvoke(CodeStatementCollection statements, bool printCode) {
            CompilerParameters cp = new CompilerParameters();
            cp.ReferencedAssemblies.Add( "System.dll" );
            cp.GenerateInMemory = true;
            CodeGeneratorOptions cgo = new CodeGeneratorOptions ();
            CodeDomProvider cpd = new CSharpCodeProvider ();
            CodeCompileUnit cu = generateCompileUnit (statements);
            StringWriter sw = new StringWriter();
            cpd.GenerateCodeFromCompileUnit(cu, sw, cgo);
            if (printCode) {
                System.Console.WriteLine (sw.ToString ());
            }

            var result = cpd.CompileAssemblyFromDom (cp, cu);

            if (result.Errors.Count != 0) {
                return -1;
            } else {
                var assembly = result.CompiledAssembly;
                var type = assembly.GetType ("CodeGolf.DigitSum");
                var method = type.GetMethod ("digitsum");
                long fitness = CalcFitness (method);
                return fitness;
            }
        }

        public static long CalcFitness(MethodInfo method) {
            long result = 0;
            for (int i = 0; i < correctValues.Length; i++) {
                int r = (int)method.Invoke (null, new Object[] { i });
                result += Math.Abs (r - correctValues[i]);
            }
            return result;
        }

        public static CodeStatementCollection generateCodeDomFromString (Term[] terms) {
            CodeStatementCollection statements = new CodeStatementCollection ();
            CodeExpression expression = null;
            foreach (Term term in terms) {
                CodeExpression inner = new CodeArgumentReferenceExpression ("i");
                if (term.and.HasValue) {
                    inner = new CodeBinaryOperatorExpression (inner, CodeBinaryOperatorType.BitwiseAnd, new CodePrimitiveExpression(term.and.Value));
                }
                if (term.shift.HasValue) {
                    inner = new CodeBinaryOperatorExpression (inner, CodeBinaryOperatorType.Divide, new CodePrimitiveExpression(Math.Pow (2, term.shift.Value)));
                }
                if (expression == null) {
                    expression = inner;
                } else {
                    expression = new CodeBinaryOperatorExpression (expression, CodeBinaryOperatorType.Add, inner);
                }
            }
            statements.Add (new CodeMethodReturnStatement (expression));
            return statements;
        }

        public static void Main (string[] args)
        {
            correctValues = new int[10001];
            for (int i = 0; i < correctValues.Length; i++) {
                int result = 0;
                int num = i;
                while (num != 0) {
                    result += num % BASE;
                    num /= BASE;
                }
                correctValues [i] = result;
            }
            values.Add (new Evolution (new Term[] { new Term (null, null) }));
            Random rnd = new Random ();
            while (true) {
                // run old generation
                foreach (var val in values) {
                    CodeStatementCollection stat = generateCodeDomFromString (val.term);
                    long fitness = CompileAndInvoke (stat, false);
                    val.score = fitness;
                    System.Console.WriteLine ("Fitness: {0}", fitness);
                }
                Evolution best = values.Aggregate ((i1, i2) => i1.score < i2.score ? i1 : i2);
                CodeStatementCollection bestcoll = generateCodeDomFromString (best.term);
                CompileAndInvoke (bestcoll, true);
                System.Console.WriteLine ("Best fitness for this run: {0}", best.score);

                if (best.score == 0)
                    break;

                // generate new generation
                List<Evolution> top = values.OrderBy (i => i.score).Take (3).ToList();
                values = new List<Evolution> ();
                foreach (var e in top) {
                    values.Add (e);
                    if (e.term.Length < 16) {
                        Term[] newTerm = new Term[e.term.Length + 1];
                        for (int i = 0; i < e.term.Length; i++) {
                            newTerm [i] = e.term [i];
                        }
                        int rrr = rnd.Next (0, 17);
                        newTerm [e.term.Length] = new Term ((int)Math.Pow(2,rrr), rrr);
                        values.Add (new Evolution (newTerm));
                    }
                    {
                        int r = rnd.Next (0, e.term.Length);
                        Term[] newTerm = (Term[])e.term.Clone ();
                        int rrr = rnd.Next (0, 17);
                        newTerm [r] = new Term ((int)Math.Pow(2,rrr), rrr);
                        values.Add (new Evolution (newTerm));
                    }
                }
            }
        }

        public struct Term {
            public int? and;
            public int? shift;

            public Term(int? and, int? shift) {
                if (and!=0) {
                    this.and = and;
                } else this.and = null;
                if (shift!=0) {
                    this.shift = shift;
                } else this.shift=null;
            }
        }

        public class Evolution {
            public Term[] term;
            public long score;

            public Evolution(Term[] term) {
                this.term = term;
            }
        }
    }
}

Tested on OSX with Mono C# compiler version 3.2.6.0.
At each iteration it prints the fitness value of the current calculation. At the end it will print the best solution along with its fitness. The loop will run until one of the results have a fitness value of 0.
This is how it starts:
// ------------------------------------------------------------------------------
//  <autogenerated>
//      This code was generated by a tool.
//      Mono Runtime Version: 4.0.30319.17020
//
//      Changes to this file may cause incorrect behavior and will be lost if
//      the code is regenerated.
//  </autogenerated>
// ------------------------------------------------------------------------------

namespace CodeGolf {
    using System;

    public class DigitSum {

        public static int digitsum(int i) {
            return i;
        }
    }
}

Best fitness for this run: 49940387

And after a while (takes around 30 minutes), this is how it ends (showing the last and almost last iteration):
// ------------------------------------------------------------------------------
//  <autogenerated>
//      This code was generated by a tool.
//      Mono Runtime Version: 4.0.30319.17020
//
//      Changes to this file may cause incorrect behavior and will be lost if
//      the code is regenerated.
//  </autogenerated>
// ------------------------------------------------------------------------------

namespace CodeGolf {
    using System;

    public class DigitSum {

        public static int digitsum(int i) {
            return ((((((((((((((((i & 4096) / 4096) + ((i & 16) / 16)) + ((i & 32) / 32)) + ((i & 128) / 128)) + ((i & 65536) / 65536)) + ((i & 1024) / 1024)) + ((i & 8) / 8)) + ((i & 2) / 2)) + ((i & 512) / 512)) + ((i & 4) / 4)) + (i & 1)) + ((i & 256) / 256)) + ((i & 128) / 128)) + ((i & 8192) / 8192)) + ((i & 2048) / 2048));
        }
    }
}

Best fitness for this run: 4992
Fitness: 4992
Fitness: 7040
Fitness: 4993
Fitness: 4992
Fitness: 0
Fitness: 4992
Fitness: 4992
Fitness: 7496
// ------------------------------------------------------------------------------
//  <autogenerated>
//      This code was generated by a tool.
//      Mono Runtime Version: 4.0.30319.17020
//
//      Changes to this file may cause incorrect behavior and will be lost if
//      the code is regenerated.
//  </autogenerated>
// ------------------------------------------------------------------------------

namespace CodeGolf {
    using System;

    public class DigitSum {

        public static int digitsum(int i) {
            return (((((((((((((((((i & 4096) / 4096) + ((i & 16) / 16)) + ((i & 32) / 32)) + ((i & 64) / 64)) + ((i & 32768) / 32768)) + ((i & 1024) / 1024)) + ((i & 8) / 8)) + ((i & 2) / 2)) + ((i & 512) / 512)) + ((i & 4) / 4)) + (i & 1)) + ((i & 256) / 256)) + ((i & 128) / 128)) + ((i & 8192) / 8192)) + ((i & 2048) / 2048)) + ((i & 32768) / 32768));
        }
    }
}

Best fitness for this run: 0

Notes:

CodeDOM doesn't support the left shift operator so instead of a >> b I'm using a / 2^b
The initial iteration is just a return i; as required by the problem.
In the first few iterations priority is given to adding new terms (genes) to the sum. Later there is more priority in changing values (mutation) in terms randomly.
I'm generating terms that look like i & a >> a instead of i & a >> b, as in the latter case the evolution was simply too slow to be practical.
This is also why the solution is limited to finding an answer in the form return (i&a>>b)+(i&c>>d)+..., as any other kind (like trying to generate a "proper" code, with loops, assignments, condition checks, etc.) would simply converge too slowly. Also this way it is very easy to define the genes (each of the term), and is very easy to mutate them.
This is also the reason why I'm adding the digits in base 2 (the base wasn't specified in the problem statement, so I consider this fine). A base 10 solution would've been just to slow, and also it would've been really hard to define the actual genes. Adding a loop would also mean that you have to manage the running code, and find a possible way to kill it, before it enters a potentially infinite loop.
Genes are only mutated, there is no crossover in this solution. I don't know whether adding that would speed up the evolution process or not.
The solution is only tested for numbers 0..10000 (if you check the found solution you can see that it won't work for numbers larger than 16384)
The whole evolution process can be checked at this gist.

Javascript
Well, I got some floating point precision issue with my answer - that can probably be solved using a BigDecimal library - when input numbers are larger than 55.
Yes, that's far from 10000 so I don't expect to win but still an interesting method based on this topic.
It compute a [polynomial interpolation] (http://en.wikipedia.org/wiki/Polynomial_interpolation) based on a set of points, so it use only multiplication, division and addition, no modulo or bitwise operators.
//used to compute real values
function correct(i) {
  var s = i.toString();
  var o=0;
  for (var i=0; i<s.length; i++) {
    o+=parseInt(s[i]);
  }
  return o;
}

function digitsum(i){return i}
//can be replaced by anything like :
//function digitsum(i){return (Math.sin(i*i)+2*Math.sqrt(i)))}

for (var j=0; j<60; j++) {
  var p = correct(j+1)-digitsum(j+1);
  if (p != 0) {
    var g='Math.round(1';
    for (var k=0; k<j+1; k++) {
      g+='*((i-'+k+')/'+(j+1-k)+')';
    }
    g+=')';
    eval(digitsum.toString().replace(/{return (.*)}/, function (m,v) {
      return "{return "+v+"+"+p+"*"+g+"}";
    }));
  }
}

console.log(digitsum);

Output function :
function digitsum(i){return i+-9*Math.round(1*((i-0)/10)*((i-1)/9)*((i-2)/8)*((i-3)/7)*((i-4)/6)*((i-5)/5)*((i-6)/4)*((i-7)/3)*((i-8)/2)*((i-9)/1))+90*Math.round(1*((i-0)/11)*((i-1)/10)*((i-2)/9)*((i-3)/8)*((i-4)/7)*((i-5)/6)*((i-6)/5)*((i-7)/4)*((i-8)/3)*((i-9)/2)*((i-10)/1))+-495*Math.round(1*((i-0)/12)*((i-1)/11)*((i-2)/10)*((i-3)/9)*((i-4)/8)*((i-5)/7)*((i-6)/6)*((i-7)/5)*((i-8)/4)*((i-9)/3)*((i-10)/2)*((i-11)/1))+1980*Math.round(1*((i-0)/13)*((i-1)/12)*((i-2)/11)*((i-3)/10)*((i-4)/9)*((i-5)/8)*((i-6)/7)*((i-7)/6)*((i-8)/5)*((i-9)/4)*((i-10)/3)*((i-11)/2)*((i-12)/1))+-6435*Math.round(1*((i-0)/14)*((i-1)/13)*((i-2)/12)*((i-3)/11)*((i-4)/10)*((i-5)/9)*((i-6)/8)*((i-7)/7)*((i-8)/6)*((i-9)/5)*((i-10)/4)*((i-11)/3)*((i-12)/2)*((i-13)/1))+18018*Math.round(1*((i-0)/15)*((i-1)/14)*((i-2)/13)*((i-3)/12)*((i-4)/11)*((i-5)/10)*((i-6)/9)*((i-7)/8)*((i-8)/7)*((i-9)/6)*((i-10)/5)*((i-11)/4)*((i-12)/3)*((i-13)/2)*((i-14)/1))+-45045*Math.round(1*((i-0)/16)*((i-1)/15)*((i-2)/14)*((i-3)/13)*((i-4)/12)*((i-5)/11)*((i-6)/10)*((i-7)/9)*((i-8)/8)*((i-9)/7)*((i-10)/6)*((i-11)/5)*((i-12)/4)*((i-13)/3)*((i-14)/2)*((i-15)/1))+102960*Math.round(1*((i-0)/17)*((i-1)/16)*((i-2)/15)*((i-3)/14)*((i-4)/13)*((i-5)/12)*((i-6)/11)*((i-7)/10)*((i-8)/9)*((i-9)/8)*((i-10)/7)*((i-11)/6)*((i-12)/5)*((i-13)/4)*((i-14)/3)*((i-15)/2)*((i-16)/1))+-218790*Math.round(1*((i-0)/18)*((i-1)/17)*((i-2)/16)*((i-3)/15)*((i-4)/14)*((i-5)/13)*((i-6)/12)*((i-7)/11)*((i-8)/10)*((i-9)/9)*((i-10)/8)*((i-11)/7)*((i-12)/6)*((i-13)/5)*((i-14)/4)*((i-15)/3)*((i-16)/2)*((i-17)/1))+437580*Math.round(1*((i-0)/19)*((i-1)/18)*((i-2)/17)*((i-3)/16)*((i-4)/15)*((i-5)/14)*((i-6)/13)*((i-7)/12)*((i-8)/11)*((i-9)/10)*((i-10)/9)*((i-11)/8)*((i-12)/7)*((i-13)/6)*((i-14)/5)*((i-15)/4)*((i-16)/3)*((i-17)/2)*((i-18)/1))+-831411*Math.round(1*((i-0)/20)*((i-1)/19)*((i-2)/18)*((i-3)/17)*((i-4)/16)*((i-5)/15)*((i-6)/14)*((i-7)/13)*((i-8)/12)*((i-9)/11)*((i-10)/10)*((i-11)/9)*((i-12)/8)*((i-13)/7)*((i-14)/6)*((i-15)/5)*((i-16)/4)*((i-17)/3)*((i-18)/2)*((i-19)/1))+1511820*Math.round(1*((i-0)/21)*((i-1)/20)*((i-2)/19)*((i-3)/18)*((i-4)/17)*((i-5)/16)*((i-6)/15)*((i-7)/14)*((i-8)/13)*((i-9)/12)*((i-10)/11)*((i-11)/10)*((i-12)/9)*((i-13)/8)*((i-14)/7)*((i-15)/6)*((i-16)/5)*((i-17)/4)*((i-18)/3)*((i-19)/2)*((i-20)/1))+-2647260*Math.round(1*((i-0)/22)*((i-1)/21)*((i-2)/20)*((i-3)/19)*((i-4)/18)*((i-5)/17)*((i-6)/16)*((i-7)/15)*((i-8)/14)*((i-9)/13)*((i-10)/12)*((i-11)/11)*((i-12)/10)*((i-13)/9)*((i-14)/8)*((i-15)/7)*((i-16)/6)*((i-17)/5)*((i-18)/4)*((i-19)/3)*((i-20)/2)*((i-21)/1))+4490640*Math.round(1*((i-0)/23)*((i-1)/22)*((i-2)/21)*((i-3)/20)*((i-4)/19)*((i-5)/18)*((i-6)/17)*((i-7)/16)*((i-8)/15)*((i-9)/14)*((i-10)/13)*((i-11)/12)*((i-12)/11)*((i-13)/10)*((i-14)/9)*((i-15)/8)*((i-16)/7)*((i-17)/6)*((i-18)/5)*((i-19)/4)*((i-20)/3)*((i-21)/2)*((i-22)/1))+-7434405*Math.round(1*((i-0)/24)*((i-1)/23)*((i-2)/22)*((i-3)/21)*((i-4)/20)*((i-5)/19)*((i-6)/18)*((i-7)/17)*((i-8)/16)*((i-9)/15)*((i-10)/14)*((i-11)/13)*((i-12)/12)*((i-13)/11)*((i-14)/10)*((i-15)/9)*((i-16)/8)*((i-17)/7)*((i-18)/6)*((i-19)/5)*((i-20)/4)*((i-21)/3)*((i-22)/2)*((i-23)/1))+12150072*Math.round(1*((i-0)/25)*((i-1)/24)*((i-2)/23)*((i-3)/22)*((i-4)/21)*((i-5)/20)*((i-6)/19)*((i-7)/18)*((i-8)/17)*((i-9)/16)*((i-10)/15)*((i-11)/14)*((i-12)/13)*((i-13)/12)*((i-14)/11)*((i-15)/10)*((i-16)/9)*((i-17)/8)*((i-18)/7)*((i-19)/6)*((i-20)/5)*((i-21)/4)*((i-22)/3)*((i-23)/2)*((i-24)/1))+-19980675*Math.round(1*((i-0)/26)*((i-1)/25)*((i-2)/24)*((i-3)/23)*((i-4)/22)*((i-5)/21)*((i-6)/20)*((i-7)/19)*((i-8)/18)*((i-9)/17)*((i-10)/16)*((i-11)/15)*((i-12)/14)*((i-13)/13)*((i-14)/12)*((i-15)/11)*((i-16)/10)*((i-17)/9)*((i-18)/8)*((i-19)/7)*((i-20)/6)*((i-21)/5)*((i-22)/4)*((i-23)/3)*((i-24)/2)*((i-25)/1))+34041150*Math.round(1*((i-0)/27)*((i-1)/26)*((i-2)/25)*((i-3)/24)*((i-4)/23)*((i-5)/22)*((i-6)/21)*((i-7)/20)*((i-8)/19)*((i-9)/18)*((i-10)/17)*((i-11)/16)*((i-12)/15)*((i-13)/14)*((i-14)/13)*((i-15)/12)*((i-16)/11)*((i-17)/10)*((i-18)/9)*((i-19)/8)*((i-20)/7)*((i-21)/6)*((i-22)/5)*((i-23)/4)*((i-24)/3)*((i-25)/2)*((i-26)/1))+-62162100*Math.round(1*((i-0)/28)*((i-1)/27)*((i-2)/26)*((i-3)/25)*((i-4)/24)*((i-5)/23)*((i-6)/22)*((i-7)/21)*((i-8)/20)*((i-9)/19)*((i-10)/18)*((i-11)/17)*((i-12)/16)*((i-13)/15)*((i-14)/14)*((i-15)/13)*((i-16)/12)*((i-17)/11)*((i-18)/10)*((i-19)/9)*((i-20)/8)*((i-21)/7)*((i-22)/6)*((i-23)/5)*((i-24)/4)*((i-25)/3)*((i-26)/2)*((i-27)/1))+124324200*Math.round(1*((i-0)/29)*((i-1)/28)*((i-2)/27)*((i-3)/26)*((i-4)/25)*((i-5)/24)*((i-6)/23)*((i-7)/22)*((i-8)/21)*((i-9)/20)*((i-10)/19)*((i-11)/18)*((i-12)/17)*((i-13)/16)*((i-14)/15)*((i-15)/14)*((i-16)/13)*((i-17)/12)*((i-18)/11)*((i-19)/10)*((i-20)/9)*((i-21)/8)*((i-22)/7)*((i-23)/6)*((i-24)/5)*((i-25)/4)*((i-26)/3)*((i-27)/2)*((i-28)/1))+-270405144*Math.round(1*((i-0)/30)*((i-1)/29)*((i-2)/28)*((i-3)/27)*((i-4)/26)*((i-5)/25)*((i-6)/24)*((i-7)/23)*((i-8)/22)*((i-9)/21)*((i-10)/20)*((i-11)/19)*((i-12)/18)*((i-13)/17)*((i-14)/16)*((i-15)/15)*((i-16)/14)*((i-17)/13)*((i-18)/12)*((i-19)/11)*((i-20)/10)*((i-21)/9)*((i-22)/8)*((i-23)/7)*((i-24)/6)*((i-25)/5)*((i-26)/4)*((i-27)/3)*((i-28)/2)*((i-29)/1))+620410320*Math.round(1*((i-0)/31)*((i-1)/30)*((i-2)/29)*((i-3)/28)*((i-4)/27)*((i-5)/26)*((i-6)/25)*((i-7)/24)*((i-8)/23)*((i-9)/22)*((i-10)/21)*((i-11)/20)*((i-12)/19)*((i-13)/18)*((i-14)/17)*((i-15)/16)*((i-16)/15)*((i-17)/14)*((i-18)/13)*((i-19)/12)*((i-20)/11)*((i-21)/10)*((i-22)/9)*((i-23)/8)*((i-24)/7)*((i-25)/6)*((i-26)/5)*((i-27)/4)*((i-28)/3)*((i-29)/2)*((i-30)/1))+-1451529585*Math.round(1*((i-0)/32)*((i-1)/31)*((i-2)/30)*((i-3)/29)*((i-4)/28)*((i-5)/27)*((i-6)/26)*((i-7)/25)*((i-8)/24)*((i-9)/23)*((i-10)/22)*((i-11)/21)*((i-12)/20)*((i-13)/19)*((i-14)/18)*((i-15)/17)*((i-16)/16)*((i-17)/15)*((i-18)/14)*((i-19)/13)*((i-20)/12)*((i-21)/11)*((i-22)/10)*((i-23)/9)*((i-24)/8)*((i-25)/7)*((i-26)/6)*((i-27)/5)*((i-28)/4)*((i-29)/3)*((i-30)/2)*((i-31)/1))+3378846240*Math.round(1*((i-0)/33)*((i-1)/32)*((i-2)/31)*((i-3)/30)*((i-4)/29)*((i-5)/28)*((i-6)/27)*((i-7)/26)*((i-8)/25)*((i-9)/24)*((i-10)/23)*((i-11)/22)*((i-12)/21)*((i-13)/20)*((i-14)/19)*((i-15)/18)*((i-16)/17)*((i-17)/16)*((i-18)/15)*((i-19)/14)*((i-20)/13)*((i-21)/12)*((i-22)/11)*((i-23)/10)*((i-24)/9)*((i-25)/8)*((i-26)/7)*((i-27)/6)*((i-28)/5)*((i-29)/4)*((i-30)/3)*((i-31)/2)*((i-32)/1))+-7716754980*Math.round(1*((i-0)/34)*((i-1)/33)*((i-2)/32)*((i-3)/31)*((i-4)/30)*((i-5)/29)*((i-6)/28)*((i-7)/27)*((i-8)/26)*((i-9)/25)*((i-10)/24)*((i-11)/23)*((i-12)/22)*((i-13)/21)*((i-14)/20)*((i-15)/19)*((i-16)/18)*((i-17)/17)*((i-18)/16)*((i-19)/15)*((i-20)/14)*((i-21)/13)*((i-22)/12)*((i-23)/11)*((i-24)/10)*((i-25)/9)*((i-26)/8)*((i-27)/7)*((i-28)/6)*((i-29)/5)*((i-30)/4)*((i-31)/3)*((i-32)/2)*((i-33)/1))+17178273288*Math.round(1*((i-0)/35)*((i-1)/34)*((i-2)/33)*((i-3)/32)*((i-4)/31)*((i-5)/30)*((i-6)/29)*((i-7)/28)*((i-8)/27)*((i-9)/26)*((i-10)/25)*((i-11)/24)*((i-12)/23)*((i-13)/22)*((i-14)/21)*((i-15)/20)*((i-16)/19)*((i-17)/18)*((i-18)/17)*((i-19)/16)*((i-20)/15)*((i-21)/14)*((i-22)/13)*((i-23)/12)*((i-24)/11)*((i-25)/10)*((i-26)/9)*((i-27)/8)*((i-28)/7)*((i-29)/6)*((i-30)/5)*((i-31)/4)*((i-32)/3)*((i-33)/2)*((i-34)/1))+-37189436130*Math.round(1*((i-0)/36)*((i-1)/35)*((i-2)/34)*((i-3)/33)*((i-4)/32)*((i-5)/31)*((i-6)/30)*((i-7)/29)*((i-8)/28)*((i-9)/27)*((i-10)/26)*((i-11)/25)*((i-12)/24)*((i-13)/23)*((i-14)/22)*((i-15)/21)*((i-16)/20)*((i-17)/19)*((i-18)/18)*((i-19)/17)*((i-20)/16)*((i-21)/15)*((i-22)/14)*((i-23)/13)*((i-24)/12)*((i-25)/11)*((i-26)/10)*((i-27)/9)*((i-28)/8)*((i-29)/7)*((i-30)/6)*((i-31)/5)*((i-32)/4)*((i-33)/3)*((i-34)/2)*((i-35)/1))+78299888041*Math.round(1*((i-0)/37)*((i-1)/36)*((i-2)/35)*((i-3)/34)*((i-4)/33)*((i-5)/32)*((i-6)/31)*((i-7)/30)*((i-8)/29)*((i-9)/28)*((i-10)/27)*((i-11)/26)*((i-12)/25)*((i-13)/24)*((i-14)/23)*((i-15)/22)*((i-16)/21)*((i-17)/20)*((i-18)/19)*((i-19)/18)*((i-20)/17)*((i-21)/16)*((i-22)/15)*((i-23)/14)*((i-24)/13)*((i-25)/12)*((i-26)/11)*((i-27)/10)*((i-28)/9)*((i-29)/8)*((i-30)/7)*((i-31)/6)*((i-32)/5)*((i-33)/4)*((i-34)/3)*((i-35)/2)*((i-36)/1))+-160520791904*Math.round(1*((i-0)/38)*((i-1)/37)*((i-2)/36)*((i-3)/35)*((i-4)/34)*((i-5)/33)*((i-6)/32)*((i-7)/31)*((i-8)/30)*((i-9)/29)*((i-10)/28)*((i-11)/27)*((i-12)/26)*((i-13)/25)*((i-14)/24)*((i-15)/23)*((i-16)/22)*((i-17)/21)*((i-18)/20)*((i-19)/19)*((i-20)/18)*((i-21)/17)*((i-22)/16)*((i-23)/15)*((i-24)/14)*((i-25)/13)*((i-26)/12)*((i-27)/11)*((i-28)/10)*((i-29)/9)*((i-30)/8)*((i-31)/7)*((i-32)/6)*((i-33)/5)*((i-34)/4)*((i-35)/3)*((i-36)/2)*((i-37)/1))+321041584713*Math.round(1*((i-0)/39)*((i-1)/38)*((i-2)/37)*((i-3)/36)*((i-4)/35)*((i-5)/34)*((i-6)/33)*((i-7)/32)*((i-8)/31)*((i-9)/30)*((i-10)/29)*((i-11)/28)*((i-12)/27)*((i-13)/26)*((i-14)/25)*((i-15)/24)*((i-16)/23)*((i-17)/22)*((i-18)/21)*((i-19)/20)*((i-20)/19)*((i-21)/18)*((i-22)/17)*((i-23)/16)*((i-24)/15)*((i-25)/14)*((i-26)/13)*((i-27)/12)*((i-28)/11)*((i-29)/10)*((i-30)/9)*((i-31)/8)*((i-32)/7)*((i-33)/6)*((i-34)/5)*((i-35)/4)*((i-36)/3)*((i-37)/2)*((i-38)/1))+-627938339760*Math.round(1*((i-0)/40)*((i-1)/39)*((i-2)/38)*((i-3)/37)*((i-4)/36)*((i-5)/35)*((i-6)/34)*((i-7)/33)*((i-8)/32)*((i-9)/31)*((i-10)/30)*((i-11)/29)*((i-12)/28)*((i-13)/27)*((i-14)/26)*((i-15)/25)*((i-16)/24)*((i-17)/23)*((i-18)/22)*((i-19)/21)*((i-20)/20)*((i-21)/19)*((i-22)/18)*((i-23)/17)*((i-24)/16)*((i-25)/15)*((i-26)/14)*((i-27)/13)*((i-28)/12)*((i-29)/11)*((i-30)/10)*((i-31)/9)*((i-32)/8)*((i-33)/7)*((i-34)/6)*((i-35)/5)*((i-36)/4)*((i-37)/3)*((i-38)/2)*((i-39)/1))+1204809019815*Math.round(1*((i-0)/41)*((i-1)/40)*((i-2)/39)*((i-3)/38)*((i-4)/37)*((i-5)/36)*((i-6)/35)*((i-7)/34)*((i-8)/33)*((i-9)/32)*((i-10)/31)*((i-11)/30)*((i-12)/29)*((i-13)/28)*((i-14)/27)*((i-15)/26)*((i-16)/25)*((i-17)/24)*((i-18)/23)*((i-19)/22)*((i-20)/21)*((i-21)/20)*((i-22)/19)*((i-23)/18)*((i-24)/17)*((i-25)/16)*((i-26)/15)*((i-27)/14)*((i-28)/13)*((i-29)/12)*((i-30)/11)*((i-31)/10)*((i-32)/9)*((i-33)/8)*((i-34)/7)*((i-35)/6)*((i-36)/5)*((i-37)/4)*((i-38)/3)*((i-39)/2)*((i-40)/1))+-2276206770520*Math.round(1*((i-0)/42)*((i-1)/41)*((i-2)/40)*((i-3)/39)*((i-4)/38)*((i-5)/37)*((i-6)/36)*((i-7)/35)*((i-8)/34)*((i-9)/33)*((i-10)/32)*((i-11)/31)*((i-12)/30)*((i-13)/29)*((i-14)/28)*((i-15)/27)*((i-16)/26)*((i-17)/25)*((i-18)/24)*((i-19)/23)*((i-20)/22)*((i-21)/21)*((i-22)/20)*((i-23)/19)*((i-24)/18)*((i-25)/17)*((i-26)/16)*((i-27)/15)*((i-28)/14)*((i-29)/13)*((i-30)/12)*((i-31)/11)*((i-32)/10)*((i-33)/9)*((i-34)/8)*((i-35)/7)*((i-36)/6)*((i-37)/5)*((i-38)/4)*((i-39)/3)*((i-40)/2)*((i-41)/1))+4254673762574*Math.round(1*((i-0)/43)*((i-1)/42)*((i-2)/41)*((i-3)/40)*((i-4)/39)*((i-5)/38)*((i-6)/37)*((i-7)/36)*((i-8)/35)*((i-9)/34)*((i-10)/33)*((i-11)/32)*((i-12)/31)*((i-13)/30)*((i-14)/29)*((i-15)/28)*((i-16)/27)*((i-17)/26)*((i-18)/25)*((i-19)/24)*((i-20)/23)*((i-21)/22)*((i-22)/21)*((i-23)/20)*((i-24)/19)*((i-25)/18)*((i-26)/17)*((i-27)/16)*((i-28)/15)*((i-29)/14)*((i-30)/13)*((i-31)/12)*((i-32)/11)*((i-33)/10)*((i-34)/9)*((i-35)/8)*((i-36)/7)*((i-37)/6)*((i-38)/5)*((i-39)/4)*((i-40)/3)*((i-41)/2)*((i-42)/1))+-7914840120452*Math.round(1*((i-0)/44)*((i-1)/43)*((i-2)/42)*((i-3)/41)*((i-4)/40)*((i-5)/39)*((i-6)/38)*((i-7)/37)*((i-8)/36)*((i-9)/35)*((i-10)/34)*((i-11)/33)*((i-12)/32)*((i-13)/31)*((i-14)/30)*((i-15)/29)*((i-16)/28)*((i-17)/27)*((i-18)/26)*((i-19)/25)*((i-20)/24)*((i-21)/23)*((i-22)/22)*((i-23)/21)*((i-24)/20)*((i-25)/19)*((i-26)/18)*((i-27)/17)*((i-28)/16)*((i-29)/15)*((i-30)/14)*((i-31)/13)*((i-32)/12)*((i-33)/11)*((i-34)/10)*((i-35)/9)*((i-36)/8)*((i-37)/7)*((i-38)/6)*((i-39)/5)*((i-40)/4)*((i-41)/3)*((i-42)/2)*((i-43)/1))+14755713366633*Math.round(1*((i-0)/45)*((i-1)/44)*((i-2)/43)*((i-3)/42)*((i-4)/41)*((i-5)/40)*((i-6)/39)*((i-7)/38)*((i-8)/37)*((i-9)/36)*((i-10)/35)*((i-11)/34)*((i-12)/33)*((i-13)/32)*((i-14)/31)*((i-15)/30)*((i-16)/29)*((i-17)/28)*((i-18)/27)*((i-19)/26)*((i-20)/25)*((i-21)/24)*((i-22)/23)*((i-23)/22)*((i-24)/21)*((i-25)/20)*((i-26)/19)*((i-27)/18)*((i-28)/17)*((i-29)/16)*((i-30)/15)*((i-31)/14)*((i-32)/13)*((i-33)/12)*((i-34)/11)*((i-35)/10)*((i-36)/9)*((i-37)/8)*((i-38)/7)*((i-39)/6)*((i-40)/5)*((i-41)/4)*((i-42)/3)*((i-43)/2)*((i-44)/1))+-27776520662160*Math.round(1*((i-0)/46)*((i-1)/45)*((i-2)/44)*((i-3)/43)*((i-4)/42)*((i-5)/41)*((i-6)/40)*((i-7)/39)*((i-8)/38)*((i-9)/37)*((i-10)/36)*((i-11)/35)*((i-12)/34)*((i-13)/33)*((i-14)/32)*((i-15)/31)*((i-16)/30)*((i-17)/29)*((i-18)/28)*((i-19)/27)*((i-20)/26)*((i-21)/25)*((i-22)/24)*((i-23)/23)*((i-24)/22)*((i-25)/21)*((i-26)/20)*((i-27)/19)*((i-28)/18)*((i-29)/17)*((i-30)/16)*((i-31)/15)*((i-32)/14)*((i-33)/13)*((i-34)/12)*((i-35)/11)*((i-36)/10)*((i-37)/9)*((i-38)/8)*((i-39)/7)*((i-40)/6)*((i-41)/5)*((i-42)/4)*((i-43)/3)*((i-44)/2)*((i-45)/1))+53164054207611*Math.round(1*((i-0)/47)*((i-1)/46)*((i-2)/45)*((i-3)/44)*((i-4)/43)*((i-5)/42)*((i-6)/41)*((i-7)/40)*((i-8)/39)*((i-9)/38)*((i-10)/37)*((i-11)/36)*((i-12)/35)*((i-13)/34)*((i-14)/33)*((i-15)/32)*((i-16)/31)*((i-17)/30)*((i-18)/29)*((i-19)/28)*((i-20)/27)*((i-21)/26)*((i-22)/25)*((i-23)/24)*((i-24)/23)*((i-25)/22)*((i-26)/21)*((i-27)/20)*((i-28)/19)*((i-29)/18)*((i-30)/17)*((i-31)/16)*((i-32)/15)*((i-33)/14)*((i-34)/13)*((i-35)/12)*((i-36)/11)*((i-37)/10)*((i-38)/9)*((i-39)/8)*((i-40)/7)*((i-41)/6)*((i-42)/5)*((i-43)/4)*((i-44)/3)*((i-45)/2)*((i-46)/1))+-103975831339140*Math.round(1*((i-0)/48)*((i-1)/47)*((i-2)/46)*((i-3)/45)*((i-4)/44)*((i-5)/43)*((i-6)/42)*((i-7)/41)*((i-8)/40)*((i-9)/39)*((i-10)/38)*((i-11)/37)*((i-12)/36)*((i-13)/35)*((i-14)/34)*((i-15)/33)*((i-16)/32)*((i-17)/31)*((i-18)/30)*((i-19)/29)*((i-20)/28)*((i-21)/27)*((i-22)/26)*((i-23)/25)*((i-24)/24)*((i-25)/23)*((i-26)/22)*((i-27)/21)*((i-28)/20)*((i-29)/19)*((i-30)/18)*((i-31)/17)*((i-32)/16)*((i-33)/15)*((i-34)/14)*((i-35)/13)*((i-36)/12)*((i-37)/11)*((i-38)/10)*((i-39)/9)*((i-40)/8)*((i-41)/7)*((i-42)/6)*((i-43)/5)*((i-44)/4)*((i-45)/3)*((i-46)/2)*((i-47)/1))+208138306632137*Math.round(1*((i-0)/49)*((i-1)/48)*((i-2)/47)*((i-3)/46)*((i-4)/45)*((i-5)/44)*((i-6)/43)*((i-7)/42)*((i-8)/41)*((i-9)/40)*((i-10)/39)*((i-11)/38)*((i-12)/37)*((i-13)/36)*((i-14)/35)*((i-15)/34)*((i-16)/33)*((i-17)/32)*((i-18)/31)*((i-19)/30)*((i-20)/29)*((i-21)/28)*((i-22)/27)*((i-23)/26)*((i-24)/25)*((i-25)/24)*((i-26)/23)*((i-27)/22)*((i-28)/21)*((i-29)/20)*((i-30)/19)*((i-31)/18)*((i-32)/17)*((i-33)/16)*((i-34)/15)*((i-35)/14)*((i-36)/13)*((i-37)/12)*((i-38)/11)*((i-39)/10)*((i-40)/9)*((i-41)/8)*((i-42)/7)*((i-43)/6)*((i-44)/5)*((i-45)/4)*((i-46)/3)*((i-47)/2)*((i-48)/1))+-425620349055645*Math.round(1*((i-0)/50)*((i-1)/49)*((i-2)/48)*((i-3)/47)*((i-4)/46)*((i-5)/45)*((i-6)/44)*((i-7)/43)*((i-8)/42)*((i-9)/41)*((i-10)/40)*((i-11)/39)*((i-12)/38)*((i-13)/37)*((i-14)/36)*((i-15)/35)*((i-16)/34)*((i-17)/33)*((i-18)/32)*((i-19)/31)*((i-20)/30)*((i-21)/29)*((i-22)/28)*((i-23)/27)*((i-24)/26)*((i-25)/25)*((i-26)/24)*((i-27)/23)*((i-28)/22)*((i-29)/21)*((i-30)/20)*((i-31)/19)*((i-32)/18)*((i-33)/17)*((i-34)/16)*((i-35)/15)*((i-36)/14)*((i-37)/13)*((i-38)/12)*((i-39)/11)*((i-40)/10)*((i-41)/9)*((i-42)/8)*((i-43)/7)*((i-44)/6)*((i-45)/5)*((i-46)/4)*((i-47)/3)*((i-48)/2)*((i-49)/1))+884722839970606*Math.round(1*((i-0)/51)*((i-1)/50)*((i-2)/49)*((i-3)/48)*((i-4)/47)*((i-5)/46)*((i-6)/45)*((i-7)/44)*((i-8)/43)*((i-9)/42)*((i-10)/41)*((i-11)/40)*((i-12)/39)*((i-13)/38)*((i-14)/37)*((i-15)/36)*((i-16)/35)*((i-17)/34)*((i-18)/33)*((i-19)/32)*((i-20)/31)*((i-21)/30)*((i-22)/29)*((i-23)/28)*((i-24)/27)*((i-25)/26)*((i-26)/25)*((i-27)/24)*((i-28)/23)*((i-29)/22)*((i-30)/21)*((i-31)/20)*((i-32)/19)*((i-33)/18)*((i-34)/17)*((i-35)/16)*((i-36)/15)*((i-37)/14)*((i-38)/13)*((i-39)/12)*((i-40)/11)*((i-41)/10)*((i-42)/9)*((i-43)/8)*((i-44)/7)*((i-45)/6)*((i-46)/5)*((i-47)/4)*((i-48)/3)*((i-49)/2)*((i-50)/1))+-1857183748827153*Math.round(1*((i-0)/52)*((i-1)/51)*((i-2)/50)*((i-3)/49)*((i-4)/48)*((i-5)/47)*((i-6)/46)*((i-7)/45)*((i-8)/44)*((i-9)/43)*((i-10)/42)*((i-11)/41)*((i-12)/40)*((i-13)/39)*((i-14)/38)*((i-15)/37)*((i-16)/36)*((i-17)/35)*((i-18)/34)*((i-19)/33)*((i-20)/32)*((i-21)/31)*((i-22)/30)*((i-23)/29)*((i-24)/28)*((i-25)/27)*((i-26)/26)*((i-27)/25)*((i-28)/24)*((i-29)/23)*((i-30)/22)*((i-31)/21)*((i-32)/20)*((i-33)/19)*((i-34)/18)*((i-35)/17)*((i-36)/16)*((i-37)/15)*((i-38)/14)*((i-39)/13)*((i-40)/12)*((i-41)/11)*((i-42)/10)*((i-43)/9)*((i-44)/8)*((i-45)/7)*((i-46)/6)*((i-47)/5)*((i-48)/4)*((i-49)/3)*((i-50)/2)*((i-51)/1))+3909404796652936*Math.round(1*((i-0)/53)*((i-1)/52)*((i-2)/51)*((i-3)/50)*((i-4)/49)*((i-5)/48)*((i-6)/47)*((i-7)/46)*((i-8)/45)*((i-9)/44)*((i-10)/43)*((i-11)/42)*((i-12)/41)*((i-13)/40)*((i-14)/39)*((i-15)/38)*((i-16)/37)*((i-17)/36)*((i-18)/35)*((i-19)/34)*((i-20)/33)*((i-21)/32)*((i-22)/31)*((i-23)/30)*((i-24)/29)*((i-25)/28)*((i-26)/27)*((i-27)/26)*((i-28)/25)*((i-29)/24)*((i-30)/23)*((i-31)/22)*((i-32)/21)*((i-33)/20)*((i-34)/19)*((i-35)/18)*((i-36)/17)*((i-37)/16)*((i-38)/15)*((i-39)/14)*((i-40)/13)*((i-41)/12)*((i-42)/11)*((i-43)/10)*((i-44)/9)*((i-45)/8)*((i-46)/7)*((i-47)/6)*((i-48)/5)*((i-49)/4)*((i-50)/3)*((i-51)/2)*((i-52)/1))+-8195615777370807*Math.round(1*((i-0)/54)*((i-1)/53)*((i-2)/52)*((i-3)/51)*((i-4)/50)*((i-5)/49)*((i-6)/48)*((i-7)/47)*((i-8)/46)*((i-9)/45)*((i-10)/44)*((i-11)/43)*((i-12)/42)*((i-13)/41)*((i-14)/40)*((i-15)/39)*((i-16)/38)*((i-17)/37)*((i-18)/36)*((i-19)/35)*((i-20)/34)*((i-21)/33)*((i-22)/32)*((i-23)/31)*((i-24)/30)*((i-25)/29)*((i-26)/28)*((i-27)/27)*((i-28)/26)*((i-29)/25)*((i-30)/24)*((i-31)/23)*((i-32)/22)*((i-33)/21)*((i-34)/20)*((i-35)/19)*((i-36)/18)*((i-37)/17)*((i-38)/16)*((i-39)/15)*((i-40)/14)*((i-41)/13)*((i-42)/12)*((i-43)/11)*((i-44)/10)*((i-45)/9)*((i-46)/8)*((i-47)/7)*((i-48)/6)*((i-49)/5)*((i-50)/4)*((i-51)/3)*((i-52)/2)*((i-53)/1))+16994979589974346*Math.round(1*((i-0)/55)*((i-1)/54)*((i-2)/53)*((i-3)/52)*((i-4)/51)*((i-5)/50)*((i-6)/49)*((i-7)/48)*((i-8)/47)*((i-9)/46)*((i-10)/45)*((i-11)/44)*((i-12)/43)*((i-13)/42)*((i-14)/41)*((i-15)/40)*((i-16)/39)*((i-17)/38)*((i-18)/37)*((i-19)/36)*((i-20)/35)*((i-21)/34)*((i-22)/33)*((i-23)/32)*((i-24)/31)*((i-25)/30)*((i-26)/29)*((i-27)/28)*((i-28)/27)*((i-29)/26)*((i-30)/25)*((i-31)/24)*((i-32)/23)*((i-33)/22)*((i-34)/21)*((i-35)/20)*((i-36)/19)*((i-37)/18)*((i-38)/17)*((i-39)/16)*((i-40)/15)*((i-41)/14)*((i-42)/13)*((i-43)/12)*((i-44)/11)*((i-45)/10)*((i-46)/9)*((i-47)/8)*((i-48)/7)*((i-49)/6)*((i-50)/5)*((i-51)/4)*((i-52)/3)*((i-53)/2)*((i-54)/1))+-34598925396029428*Math.round(1*((i-0)/56)*((i-1)/55)*((i-2)/54)*((i-3)/53)*((i-4)/52)*((i-5)/51)*((i-6)/50)*((i-7)/49)*((i-8)/48)*((i-9)/47)*((i-10)/46)*((i-11)/45)*((i-12)/44)*((i-13)/43)*((i-14)/42)*((i-15)/41)*((i-16)/40)*((i-17)/39)*((i-18)/38)*((i-19)/37)*((i-20)/36)*((i-21)/35)*((i-22)/34)*((i-23)/33)*((i-24)/32)*((i-25)/31)*((i-26)/30)*((i-27)/29)*((i-28)/28)*((i-29)/27)*((i-30)/26)*((i-31)/25)*((i-32)/24)*((i-33)/23)*((i-34)/22)*((i-35)/21)*((i-36)/20)*((i-37)/19)*((i-38)/18)*((i-39)/17)*((i-40)/16)*((i-41)/15)*((i-42)/14)*((i-43)/13)*((i-44)/12)*((i-45)/11)*((i-46)/10)*((i-47)/9)*((i-48)/8)*((i-49)/7)*((i-50)/6)*((i-51)/5)*((i-52)/4)*((i-53)/3)*((i-54)/2)*((i-55)/1))+68349348631526670*Math.round(1*((i-0)/57)*((i-1)/56)*((i-2)/55)*((i-3)/54)*((i-4)/53)*((i-5)/52)*((i-6)/51)*((i-7)/50)*((i-8)/49)*((i-9)/48)*((i-10)/47)*((i-11)/46)*((i-12)/45)*((i-13)/44)*((i-14)/43)*((i-15)/42)*((i-16)/41)*((i-17)/40)*((i-18)/39)*((i-19)/38)*((i-20)/37)*((i-21)/36)*((i-22)/35)*((i-23)/34)*((i-24)/33)*((i-25)/32)*((i-26)/31)*((i-27)/30)*((i-28)/29)*((i-29)/28)*((i-30)/27)*((i-31)/26)*((i-32)/25)*((i-33)/24)*((i-34)/23)*((i-35)/22)*((i-36)/21)*((i-37)/20)*((i-38)/19)*((i-39)/18)*((i-40)/17)*((i-41)/16)*((i-42)/15)*((i-43)/14)*((i-44)/13)*((i-45)/12)*((i-46)/11)*((i-47)/10)*((i-48)/9)*((i-49)/8)*((i-50)/7)*((i-51)/6)*((i-52)/5)*((i-53)/4)*((i-54)/3)*((i-55)/2)*((i-56)/1))+-126849859681465840*Math.round(1*((i-0)/58)*((i-1)/57)*((i-2)/56)*((i-3)/55)*((i-4)/54)*((i-5)/53)*((i-6)/52)*((i-7)/51)*((i-8)/50)*((i-9)/49)*((i-10)/48)*((i-11)/47)*((i-12)/46)*((i-13)/45)*((i-14)/44)*((i-15)/43)*((i-16)/42)*((i-17)/41)*((i-18)/40)*((i-19)/39)*((i-20)/38)*((i-21)/37)*((i-22)/36)*((i-23)/35)*((i-24)/34)*((i-25)/33)*((i-26)/32)*((i-27)/31)*((i-28)/30)*((i-29)/29)*((i-30)/28)*((i-31)/27)*((i-32)/26)*((i-33)/25)*((i-34)/24)*((i-35)/23)*((i-36)/22)*((i-37)/21)*((i-38)/20)*((i-39)/19)*((i-40)/18)*((i-41)/17)*((i-42)/16)*((i-43)/15)*((i-44)/14)*((i-45)/13)*((i-46)/12)*((i-47)/11)*((i-48)/10)*((i-49)/9)*((i-50)/8)*((i-51)/7)*((i-52)/6)*((i-53)/5)*((i-54)/4)*((i-55)/3)*((i-56)/2)*((i-57)/1))+189776303470473200*Math.round(1*((i-0)/59)*((i-1)/58)*((i-2)/57)*((i-3)/56)*((i-4)/55)*((i-5)/54)*((i-6)/53)*((i-7)/52)*((i-8)/51)*((i-9)/50)*((i-10)/49)*((i-11)/48)*((i-12)/47)*((i-13)/46)*((i-14)/45)*((i-15)/44)*((i-16)/43)*((i-17)/42)*((i-18)/41)*((i-19)/40)*((i-20)/39)*((i-21)/38)*((i-22)/37)*((i-23)/36)*((i-24)/35)*((i-25)/34)*((i-26)/33)*((i-27)/32)*((i-28)/31)*((i-29)/30)*((i-30)/29)*((i-31)/28)*((i-32)/27)*((i-33)/26)*((i-34)/25)*((i-35)/24)*((i-36)/23)*((i-37)/22)*((i-38)/21)*((i-39)/20)*((i-40)/19)*((i-41)/18)*((i-42)/17)*((i-43)/16)*((i-44)/15)*((i-45)/14)*((i-46)/13)*((i-47)/12)*((i-48)/11)*((i-49)/10)*((i-50)/9)*((i-51)/8)*((i-52)/7)*((i-53)/6)*((i-54)/5)*((i-55)/4)*((i-56)/3)*((i-57)/2)*((i-58)/1))+51028516348018696*Math.round(1*((i-0)/60)*((i-1)/59)*((i-2)/58)*((i-3)/57)*((i-4)/56)*((i-5)/55)*((i-6)/54)*((i-7)/53)*((i-8)/52)*((i-9)/51)*((i-10)/50)*((i-11)/49)*((i-12)/48)*((i-13)/47)*((i-14)/46)*((i-15)/45)*((i-16)/44)*((i-17)/43)*((i-18)/42)*((i-19)/41)*((i-20)/40)*((i-21)/39)*((i-22)/38)*((i-23)/37)*((i-24)/36)*((i-25)/35)*((i-26)/34)*((i-27)/33)*((i-28)/32)*((i-29)/31)*((i-30)/30)*((i-31)/29)*((i-32)/28)*((i-33)/27)*((i-34)/26)*((i-35)/25)*((i-36)/24)*((i-37)/23)*((i-38)/22)*((i-39)/21)*((i-40)/20)*((i-41)/19)*((i-42)/18)*((i-43)/17)*((i-44)/16)*((i-45)/15)*((i-46)/14)*((i-47)/13)*((i-48)/12)*((i-49)/11)*((i-50)/10)*((i-51)/9)*((i-52)/8)*((i-53)/7)*((i-54)/6)*((i-55)/5)*((i-56)/4)*((i-57)/3)*((i-58)/2)*((i-59)/1))}

This polynomial function (simplified to degree 25 and without rounding) plotted, look at values for whole numbers (readable for [6;19]) :

Tests :
for (var i=0; i<60; i++) { console.log(i + ' : ' + digitsum(i)) }
0 : 0
1 : 1
2 : 2
3 : 3
4 : 4
5 : 5
6 : 6
7 : 7
8 : 8
9 : 9
10 : 1
11 : 2
12 : 3
13 : 4
14 : 5
15 : 6
16 : 7
17 : 8
18 : 9
19 : 10
20 : 2
21 : 3
22 : 4
23 : 5
24 : 6
25 : 7
26 : 8
27 : 9
28 : 10
29 : 11
30 : 3
31 : 4
32 : 5
33 : 6
34 : 7
35 : 8
36 : 9
37 : 10
38 : 11
39 : 12
40 : 4
41 : 5
42 : 6
43 : 7
44 : 8
45 : 9
46 : 10
47 : 11
48 : 12
49 : 13
50 : 5
51 : 6
52 : 7
53 : 8
54 : 9
55 : 10
56 : 12 //precision issue starts here
57 : 16
58 : 16
59 : 0

+1 This is cool. Instead of a polynomial interpolation you might want to do a spline interpolation though, that should also be possible to do with an evolutionary algorithm, but it might be more precise.

@SztupY, interesting ! I'm not used to work with spline but I will certainly have a look at this method. Thanks.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes